CN111813465A - Information acquisition method, device, medium and equipment - Google Patents
Information acquisition method, device, medium and equipment Download PDFInfo
- Publication number
- CN111813465A CN111813465A CN202010565709.1A CN202010565709A CN111813465A CN 111813465 A CN111813465 A CN 111813465A CN 202010565709 A CN202010565709 A CN 202010565709A CN 111813465 A CN111813465 A CN 111813465A
- Authority
- CN
- China
- Prior art keywords
- stack
- stack frame
- frame information
- array
- acquiring
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 55
- 230000008569 process Effects 0.000 claims abstract description 13
- 230000002159 abnormal effect Effects 0.000 claims description 9
- 238000004590 computer program Methods 0.000 claims description 9
- 238000007493 shaping process Methods 0.000 claims description 8
- 230000006870 function Effects 0.000 description 37
- 238000010586 diagram Methods 0.000 description 9
- 230000003287 optical effect Effects 0.000 description 4
- 230000004044 response Effects 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 238000001514 detection method Methods 0.000 description 3
- 230000000644 propagated effect Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000000903 blocking effect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4488—Object-oriented
- G06F9/449—Object-oriented method invocation or resolution
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
The present disclosure provides a method, apparatus, medium, and device for information acquisition, the method comprising: calling a first stack function and acquiring a first stack storage object returned by the first stack function; acquiring stack frame information corresponding to each stack frame identifier of a main thread call stack in the first stack storage object from a stack frame information cache region based on the first stack storage object; the stack frame information cache region is used for storing stack frame information corresponding to a main thread call stack in a historical operation process in a healthy value pair mode. The method and the device can improve the information acquisition speed, quickly acquire the call stack information of the main thread and improve the execution efficiency of the program.
Description
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 acquiring information.
Background
In the running process of each application program of the android system, the call stack of each thread needs to be called continuously, corresponding tasks are executed by acquiring information of a call stack frame, the stack can record function calls (or called function execution sequence) in the running process of the thread, and each thread has an independent call stack. For example, when the system is stuck, the sub-thread detects that the main thread is stuck, and the call stack of the main thread is needed to analyze which method specifically causes the blocking.
The existing method for acquiring the call stack of the android main Thread generally calls a currentThread method of a Thread class to acquire a current Thread object, and then calls a getStacktrace method to acquire the call stack. The calling method is long in time consumption, and particularly when the calling stack is deep, the information of the calling stack is difficult to acquire in time, so that the efficiency of running of a program, detection of faults and the like is reduced.
BRIEF SUMMARY OF THE PRESENT DISCLOSURE
An object of the present disclosure is to provide a method, an apparatus, a medium, and a device for information acquisition, 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 an information acquisition method, including:
calling a first stack function and acquiring a first stack storage object returned by the first stack function;
acquiring stack frame information corresponding to each stack frame identifier of a main thread call stack in the first stack storage object from a stack frame information cache region based on the first stack storage object; the stack frame information cache region is used for storing stack frame information corresponding to a main thread call stack in a historical operation process in a healthy value pair mode.
Optionally, the obtaining, from a stack frame information cache area based on the first stack storage object, stack frame information corresponding to each stack frame identifier of a main thread call stack in the first stack storage object includes:
performing data processing on the first stack storage object to obtain an object pointer, an instruction offset value and a class name of the first stack storage object with an index of i, wherein i is greater than or equal to 0 and less than or equal to N-1, and N is the number of stack frames;
and traversing a pre-created call stack object in a stack frame information cache region by taking a character string consisting of the object pointer with the index of i, the instruction offset value and the class name as a character string parameter, and recording the stack frame information corresponding to the inquired stack frame identifier with the index of i as first stack frame information.
Optionally, the performing data processing on the first stack storage object to obtain an object pointer, an instruction offset value, and a class name of the first stack storage object with an index i includes:
converting the first stack storage object into a first object array;
acquiring a first element of the first object array, and strongly converting the first element into a first integer array;
acquiring the first half section of the first integer array as an object pointer, and acquiring the second half section of the first integer array as an instruction offset value;
the remainder after the first element of the first object array is obtained is the class name.
Optionally, after recording stack frame information corresponding to the queried stack frame identifier with the index i as the first stack frame information, the method further includes:
and acquiring an unrequired stack frame based on the call stack object, and marking the unrequired stack frame as second stack frame information, wherein the second stack frame information and the first stack frame information form stack frame information corresponding to the main thread call stack.
Optionally, the obtaining an unrequired stack frame and marking the unrequired stack frame as second stack frame information includes:
creating an abnormal class object, wherein the abnormal class object comprises stack frame information which is not inquired;
and calling the abnormal class object through a second stack function, acquiring an unrequired stack frame, and marking the unrequired stack frame as second stack frame information.
Optionally, the creating an exception class object, where the exception class object includes stack frame information that is not queried, includes:
constructing a second shaping array, wherein the size of the second shaping array is 2 × M, wherein M represents the number of stack frames which are not inquired; respectively inputting an object pointer and an instruction offset value of an unrequired stack frame into the first half section and the second half section of the second integer array;
constructing a second object array, wherein the size of the second object array is M +1, inputting the second integer array to the 0 index of the second object array, and inputting the unexquired class name to the rest part of the second object array;
and creating an exception class object, wherein the exception class object comprises a second stack storage object, and the second stack storage object is set to be reflected into the second object array.
Optionally, before the calling the first stack function, the method includes:
analyzing a standard file of a virtual machine layer, acquiring a first stack function address, and calling the first stack function through the first stack function address.
According to a second aspect, the present disclosure provides an information acquisition apparatus, including:
the device comprises a calling unit, a storage unit and a processing unit, wherein the calling unit is used for calling a first stack function and acquiring a first stack storage object returned by the first stack function;
an obtaining unit, configured to obtain, from a stack frame information cache area, stack frame information corresponding to each stack frame identifier of a main thread call stack in the first stack storage object based on the first stack storage object; the stack frame information cache region is used for storing stack frame information corresponding to a main thread call stack in a historical operation process in a healthy value pair mode.
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: when the method obtains the call stack, a system function is called to obtain a native layer representation of the call stack, then stack frame information is searched in a cache, if corresponding stack frame information exists in the cache, the information is stored, stack frames which are not cached are obtained through the system in a Throwable object mode, cache is established for each piece of the obtained stack frame information, and therefore, only the stack frames which are not cached are required to be converted into character strings, the information obtaining speed is improved, the call stack information of a main thread is obtained quickly, and the execution efficiency of a program 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 shows a flow diagram of an information acquisition method according to an embodiment of the disclosure;
FIG. 2 illustrates a data structure diagram of an object array according to an embodiment of the present disclosure;
FIG. 3 is a diagram illustrating a get call stack apparatus architecture according to an embodiment of the present disclosure;
FIG. 4 shows a schematic diagram of a processing unit architecture according to an embodiment of the present disclosure;
fig. 5 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 one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: 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 although the terms first, second, third, etc. may be used to describe … … in embodiments of the present disclosure, these … … should not be limited to these terms. These terms are used only to distinguish … …. For example, the first … … can also be referred to as the second … … and, similarly, the second … … can also be referred to as the 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 is also noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that an 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 article or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in the article or device in which the element is included.
Alternative embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
As shown in fig. 1, according to an embodiment of the present disclosure, the present disclosure provides an information acquisition method, including the following method steps:
step S102: calling a first stack function and acquiring a first stack storage object returned by the first stack function.
Optionally, before the calling the first stack function, the method includes: analyzing a standard file of a virtual machine layer, acquiring a first stack function address, and calling the first stack function through the first stack function address.
For the operating program developed by the android system, the operating program generally comprises a native layer developed based on an editing language such as C or C + +, an art virtual machine layer running on the native layer, and a Java assembly layer running on the art virtual machine layer. In the process of program development and execution, the Java layer can call the executable function of the native layer through the virtual machine layer to execute related tasks.
In this embodiment, when the application is started, the address of the stack function createinternalstack needs to be obtained by analyzing the ELF file of libart. The ELF file is a file with binary file, executable file, target code, shared library and core dump format, and is composed of 4 parts, namely ELF header (ELF header), Program header table (Program header table), Section (Section) and Section header table (Section header table).
In the program operation process, when a call stack of a main thread needs to be acquired, a stack function CreateInternalStackTrace is called first, the stack function returns a stack storage object back, the stack storage object back stores all information of the call stack of the main thread, and the stack storage object back is a native layer representation of the call stack.
Step S104: acquiring stack frame information corresponding to each stack frame identifier of a main thread call stack in the first stack storage object from a stack frame information cache region based on the first stack storage object; the stack frame information cache region is used for storing stack frame information corresponding to a main thread call stack in a historical operation process in a healthy value pair mode.
As one embodiment, the acquiring, from a stack frame information cache region based on the first stack storage object, stack frame information corresponding to each stack frame identifier of a main thread call stack in the first stack storage object includes the following sub-steps:
step S104-1: and performing data processing on the first stack storage object to obtain an object pointer, an instruction offset value and a class name of the first stack storage object with an index of i, wherein i is greater than or equal to 0 and less than or equal to N-1, and N is the number of stack frames.
Optionally, the step S104-1 further includes the following implementation steps: converting the first stack storage object into a first object array; acquiring a first element of the first object array, and strongly converting the first element into a first integer array; acquiring the first half section of the first integer array as an object pointer, and acquiring the second half section of the first integer array as an instruction offset value; the remainder after the first element of the first object array is obtained is the class name. The length of the first object array is N +1, wherein N represents the total number of stack frames, and the length of the first integer array is 2 × N.
The specific implementation mode is that the backtrace of the stack storage Object is converted into an Object array of the type of Object [ ], and the Object array is marked as backtraceArr; as shown in fig. 2, take the first element first of the object array backtracear; the first element, first, is strongly converted into an integer array of int [ ] type (under 32-bit operation condition) or long [ ] type (under 64-bit operation condition), and is marked as first IL; the data of the second half section of the integer array firstll is instruction offset values dexpc of all stack frames, the instruction offset values dexpc correspond to the stack frames one by one, and the first half section of the integer array firstll is an object pointer ArtMethod; the rest part of the object array backtracear except the first element first is the Class name Class corresponding to all stack frames. Assuming that the total number of stack frames is N, the length of the object array backtraceArr is N +1, the length of the integer array firstll is 2 × N, and when information of a stack frame with index i (0< ═ i < N) needs to be fetched, the stack frame is determined by the following three parts: the first part is the object pointer ArtMethod represented by firstIL [ i ], the instruction offset value dexpc represented by firstIL [ i + N ], and the Class name Class represented by backpraceArr [ i +1 ].
Step S104-2: and traversing a pre-created call stack object in a stack frame information cache region by taking a character string consisting of the object pointer with the index of i, the instruction offset value and the class name as a character string parameter, and recording the stack frame information corresponding to the inquired stack frame identifier with the index of i as first stack frame information.
The method includes the steps of pre-creating a call stack object, for example, creating a call stack object mymap, wherein parameters key and value in the call stack object mymap are both in a character string form.
Firstly, taking from the cache: i traverses from 0 to N-1, for each traversal: and querying corresponding detailed stack frame information in a call stack object mymap created by using a character string consisting of firstIL [ i ] + firstIL [ i + N ] + backstraceArr [ i ] as a first character string parameter key, if the corresponding stack frame information is found, recording the stack frame information, and marking the stack frame with index i as hit cache. And part of stack frame information is taken out from the buffer at first, and can be rapidly acquired, so that the time is saved for acquiring all stack frame information, and the efficiency is improved.
Step S104-3: and acquiring an unrequired stack frame based on the call stack object, and marking the unrequired stack frame as second stack frame information, wherein the second stack frame information and the first stack frame information form stack frame information corresponding to the main thread call stack.
Specifically, the acquiring an unrequired stack frame and marking the unrequired stack frame as second stack frame information includes the following substeps:
step S104-3-1: and creating an exception class object, wherein the exception class object comprises stack frame information which is not inquired.
The method specifically comprises the following steps: constructing a second shaping array, wherein the size of the second shaping array is 2 × M, wherein M represents the number of stack frames which are not inquired; respectively inputting an object pointer and an instruction offset value of an unrequired stack frame into the first half section and the second half section of the second integer array; constructing a second object array, wherein the size of the second object array is M +1, inputting the second integer array to the 0 index of the second object array, and inputting the unexquired class name to the rest part of the second object array; and creating an exception class object, wherein the exception class object comprises a second stack storage object, and the second stack storage object is set to be reflected into the second object array.
As a specific embodiment, the method comprises the following steps:
first, construct a second integer array, for example, construct an int [ ] type (32 bit running case) or long [ ] type (64 bit running case) first-il 2, the size of the second integer array can be recorded as 2 × M, where M represents the number of stack frames not queried; and respectively inputting an object pointer ArtMethod and an instruction offset value dexpc of the stack frame which is not queried into the first half section and the second half section of the second integer array.
Second, construct a second Object array, for example, construct an Object [ ] type Object array backstracear 2, the size of the second Object array is M +1, input the second integer array firstll 2 at the 0 index of the second Object array backstracear 2, and input the Class name Class not queried into the rest of the second Object array backstracear 2.
And thirdly, creating an abnormal class object Throwable which comprises a second stack storage object backspace 2, and setting the reflection of the second stack storage object backspace 2 as the second object array backspace Arr 2.
Step S104-3-2: and calling the abnormal class object through a second stack function, acquiring an unrequired stack frame, and marking the unrequired stack frame as second stack frame information.
Specifically, the second stack function getStackTrace of the exception class object Throwable is called, so that the stack frame information which is not queried can be obtained, and the stack frame which is not queried is marked as the second stack frame information.
And inputting the second stack frame information into the call stack object, and integrating the second stack frame information and the first stack frame information into complete main thread call stack information. And combining the first stack frame information acquired in the cache with the second stack frame information acquired to form complete main thread call stack information.
When the method obtains the call stack, a system function is called to obtain a native layer representation of the call stack, then stack frame information is searched in a cache, if corresponding stack frame information exists in the cache, the information is stored, stack frames which are not cached are obtained through the system in a Throwable object mode, cache is established for each piece of the obtained stack frame information, and therefore, only the stack frames which are not cached are required to be converted into character strings, the information obtaining speed is improved, the call stack information of a main thread is obtained quickly, and the execution efficiency of a program 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 of the above embodiment, and has the same technical effect as that of the above embodiment, and is not described again here.
As shown in fig. 3, according to an embodiment of the present disclosure, the present disclosure provides an apparatus for information acquisition, including:
a calling unit 302, configured to call a first stack function and obtain a first stack storage object returned by the first stack function.
Optionally, the calling unit 302 is further configured to analyze the virtual machine layer standard file, obtain a first stack function address, and call the first stack function through the first stack function address.
The acquisition unit 304: the stack frame information is used for acquiring stack frame information corresponding to each stack frame identifier of a main thread call stack in the first stack storage object from a stack frame information cache region based on the first stack storage object; the stack frame information cache region is used for storing stack frame information corresponding to a main thread call stack in a historical operation process in a healthy value pair mode.
As one embodiment, as shown in fig. 4, the obtaining unit 304 includes:
the processing unit 3041: the method is used for processing data of the first stack storage object to obtain an object pointer, an instruction offset value and a class name of the first stack storage object with an index of i, wherein i is greater than or equal to 0 and is less than or equal to N-1, and N is the number of stack frames.
Optionally, the processing unit 3041 is specifically configured to: converting the first stack storage object into a first object array; acquiring a first element of the first object array, and strongly converting the first element into a first integer array; acquiring the first half section of the first integer array as an object pointer, and acquiring the second half section of the first integer array as an instruction offset value; the remainder after the first element of the first object array is obtained is the class name. The length of the first object array is N +1, wherein N represents the total number of stack frames, and the length of the first integer array is 2 × N.
Traversal unit 3042: and the stack frame information is used for traversing a pre-created call stack object in a stack frame information cache region by taking a character string consisting of the object pointer with the index of i, the instruction offset value and the class name as a character string parameter, and recording the stack frame information corresponding to the queried stack frame identifier with the index of i as first stack frame information.
The marking unit 3043: and the stack frame information processing unit is used for acquiring an unrequired stack frame based on the call stack object, and marking the unrequired stack frame as second stack frame information, wherein the second stack frame information and the first stack frame information form stack frame information corresponding to the main thread call stack.
Specifically, the acquiring an unrequired stack frame and marking the unrequired stack frame as second stack frame information includes: and creating an exception class object, wherein the exception class object comprises stack frame information which is not inquired. And calling the abnormal class object through a second stack function, acquiring an unrequired stack frame, and marking the unrequired stack frame as second stack frame information.
Wherein, the creating an exception class object, which includes stack frame information that is not queried, includes: constructing a second shaping array, wherein the size of the second shaping array is 2 × M, wherein M represents the number of stack frames which are not inquired; respectively inputting an object pointer and an instruction offset value of an unrequired stack frame into the first half section and the second half section of the second integer array; constructing a second object array, wherein the size of the second object array is M +1, inputting the second integer array to the 0 index of the second object array, and inputting the unexquired class name to the rest part of the second object array; and creating an exception class object, wherein the exception class object comprises a second stack storage object, and the second stack storage object is set to be reflected into the second object array.
When the device acquires a call stack, a system function is called to obtain a native layer representation of the call stack, then stack frame information is searched in a cache, if corresponding stack frame information exists in the cache, the information is stored, stack frames which are not cached are acquired through the system in a Throwable object constructing mode, cache is established for each acquired stack frame information, and therefore, only the stack frames which are not cached are required to be converted into character strings, the information acquisition speed is increased, the call stack information of a main thread is acquired rapidly, and the execution efficiency of a program is improved.
As shown in fig. 5, 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 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. 5, 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. 5 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. 5, the electronic device may include a processing means (e.g., central processing unit, graphics processor, etc.) 501 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage means 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the electronic apparatus are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other by a bus 505. An input/output (I/O) interface 505 is also connected to bus 505.
Generally, the following devices may be connected to the I/O interface 505: input devices 506 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 505 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, etc.; storage devices 508 including, for example, magnetic tape, hard disk, etc.; and a communication device 505. The communication means 505 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. While fig. 5 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 an embodiment, the computer program may be downloaded and installed from a network via the communication means 505, or installed from the storage means 508, or installed from the ROM 502. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 501.
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 many 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 (10)
1. An information acquisition method, comprising:
calling a first stack function and acquiring a first stack storage object returned by the first stack function;
acquiring stack frame information corresponding to each stack frame identifier of a main thread call stack in the first stack storage object from a stack frame information cache region based on the first stack storage object; the stack frame information cache region is used for storing stack frame information corresponding to a main thread call stack in a historical operation process in a healthy value pair mode.
2. The method as claimed in claim 1, wherein said obtaining stack frame information corresponding to each stack frame identifier of a main thread call stack in the first stack storage object from a stack frame information cache region based on the first stack storage object comprises:
performing data processing on the first stack storage object to obtain an object pointer, an instruction offset value and a class name of the first stack storage object with an index of i, wherein i is greater than or equal to 0 and less than or equal to N-1, and N is the number of stack frames;
and traversing a pre-created call stack object in a stack frame information cache region by taking a character string consisting of the object pointer with the index of i, the instruction offset value and the class name as a character string parameter, and recording the stack frame information corresponding to the inquired stack frame identifier with the index of i as first stack frame information.
3. The method of claim 2, wherein said data processing said first stack storage object to obtain an object pointer, an instruction offset value, and a class name for said first stack storage object with index i comprises:
converting the first stack storage object into a first object array;
acquiring a first element of the first object array, and strongly converting the first element into a first integer array;
acquiring the first half section of the first integer array as an object pointer, and acquiring the second half section of the first integer array as an instruction offset value;
the remainder after the first element of the first object array is obtained is the class name.
4. The method as claimed in claim 2, wherein after recording the queried stack frame identifier with index i as the first stack frame information, further comprising:
and acquiring an unrequired stack frame based on the call stack object, and marking the unrequired stack frame as second stack frame information, wherein the second stack frame information and the first stack frame information form stack frame information corresponding to the main thread call stack.
5. The method as recited in claim 4, wherein said obtaining an unexquired stack frame and marking said unexquired stack frame as second stack frame information comprises:
creating an abnormal class object, wherein the abnormal class object comprises stack frame information which is not inquired;
and calling the abnormal class object through a second stack function, acquiring an unrequired stack frame, and marking the unrequired stack frame as second stack frame information.
6. The method of claim 5, wherein the creating an exception class object, the exception class object including stack frame information not queried, comprises:
constructing a second shaping array, wherein the size of the second shaping array is 2 × M, wherein M represents the number of stack frames which are not inquired; respectively inputting an object pointer and an instruction offset value of an unrequired stack frame into the first half section and the second half section of the second integer array;
constructing a second object array, wherein the size of the second object array is M +1, inputting the second integer array to the 0 index of the second object array, and inputting the unexquired class name to the rest part of the second object array;
and creating an exception class object, wherein the exception class object comprises a second stack storage object, and the second stack storage object is set to be reflected into the second object array.
7. The method of claim 1, wherein said invoking a first stack function is preceded by:
analyzing a standard file of a virtual machine layer, acquiring a first stack function address, and calling the first stack function through the first stack function address.
8. An information acquisition apparatus characterized by comprising:
the device comprises a calling unit, a storage unit and a processing unit, wherein the calling unit is used for calling a first stack function and acquiring a first stack storage object returned by the first stack function;
an obtaining unit, configured to obtain, from a stack frame information cache area, stack frame information corresponding to each stack frame identifier of a main thread call stack in the first stack storage object based on the first stack storage object; the stack frame information cache region is used for storing stack frame information corresponding to a main thread call stack in a historical operation process in a healthy value pair mode.
9. A computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
10. 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 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010565709.1A CN111813465B (en) | 2020-06-19 | 2020-06-19 | Information acquisition method, device, medium and equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010565709.1A CN111813465B (en) | 2020-06-19 | 2020-06-19 | Information acquisition method, device, medium and equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111813465A true CN111813465A (en) | 2020-10-23 |
CN111813465B CN111813465B (en) | 2023-11-21 |
Family
ID=72845324
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010565709.1A Active CN111813465B (en) | 2020-06-19 | 2020-06-19 | Information acquisition method, device, medium and equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111813465B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112905381A (en) * | 2021-03-22 | 2021-06-04 | 北京字节跳动网络技术有限公司 | Method, device, equipment and medium for acquiring stack frame information in call stack |
CN112925717A (en) * | 2021-03-22 | 2021-06-08 | 北京字节跳动网络技术有限公司 | Method, apparatus, device and medium for determining objects of call stack frame |
CN113238915A (en) * | 2021-05-14 | 2021-08-10 | 北京百度网讯科技有限公司 | Processing method, device, equipment, storage medium and program for calling information |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107506256A (en) * | 2017-09-07 | 2017-12-22 | 北京京东尚科信息技术有限公司 | A kind of method and apparatus of crash data monitoring |
CN110489179A (en) * | 2019-08-02 | 2019-11-22 | 北京字节跳动网络技术有限公司 | Obtain method, apparatus, medium and the equipment of call stack stack frame function signature |
CN110489165A (en) * | 2019-08-02 | 2019-11-22 | 北京字节跳动网络技术有限公司 | Obtain method, apparatus, medium and the equipment of call stack stack frame command offsets |
CN110727480A (en) * | 2019-09-05 | 2020-01-24 | 北京字节跳动网络技术有限公司 | Method, device, medium and equipment for acquiring call stack frame instruction offset |
CN110764941A (en) * | 2019-09-05 | 2020-02-07 | 北京字节跳动网络技术有限公司 | Method, device, medium and equipment for acquiring call stack frame instruction offset |
CN110865898A (en) * | 2019-10-12 | 2020-03-06 | 北京字节跳动网络技术有限公司 | Method, device, medium and equipment for clustering crash call stack |
US20200159641A1 (en) * | 2018-11-15 | 2020-05-21 | International Business Machines Corporation | Debugging asynchronous functions |
-
2020
- 2020-06-19 CN CN202010565709.1A patent/CN111813465B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107506256A (en) * | 2017-09-07 | 2017-12-22 | 北京京东尚科信息技术有限公司 | A kind of method and apparatus of crash data monitoring |
US20200159641A1 (en) * | 2018-11-15 | 2020-05-21 | International Business Machines Corporation | Debugging asynchronous functions |
CN110489179A (en) * | 2019-08-02 | 2019-11-22 | 北京字节跳动网络技术有限公司 | Obtain method, apparatus, medium and the equipment of call stack stack frame function signature |
CN110489165A (en) * | 2019-08-02 | 2019-11-22 | 北京字节跳动网络技术有限公司 | Obtain method, apparatus, medium and the equipment of call stack stack frame command offsets |
CN110727480A (en) * | 2019-09-05 | 2020-01-24 | 北京字节跳动网络技术有限公司 | Method, device, medium and equipment for acquiring call stack frame instruction offset |
CN110764941A (en) * | 2019-09-05 | 2020-02-07 | 北京字节跳动网络技术有限公司 | Method, device, medium and equipment for acquiring call stack frame instruction offset |
CN110865898A (en) * | 2019-10-12 | 2020-03-06 | 北京字节跳动网络技术有限公司 | Method, device, medium and equipment for clustering crash call stack |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112905381A (en) * | 2021-03-22 | 2021-06-04 | 北京字节跳动网络技术有限公司 | Method, device, equipment and medium for acquiring stack frame information in call stack |
CN112925717A (en) * | 2021-03-22 | 2021-06-08 | 北京字节跳动网络技术有限公司 | Method, apparatus, device and medium for determining objects of call stack frame |
WO2022199283A1 (en) * | 2021-03-22 | 2022-09-29 | 北京字节跳动网络技术有限公司 | Method and apparatus for determining object of call stack frame, device, and medium |
WO2022199331A1 (en) * | 2021-03-22 | 2022-09-29 | 北京字节跳动网络技术有限公司 | Method and apparatus for obtaining information of stack frame in call stack, device, and medium |
CN112905381B (en) * | 2021-03-22 | 2022-12-06 | 北京字节跳动网络技术有限公司 | Method, device, equipment and medium for acquiring stack frame information in call stack |
CN112925717B (en) * | 2021-03-22 | 2024-03-12 | 北京字节跳动网络技术有限公司 | Method, apparatus, device and medium for determining object of call stack frame |
CN113238915A (en) * | 2021-05-14 | 2021-08-10 | 北京百度网讯科技有限公司 | Processing method, device, equipment, storage medium and program for calling information |
CN113238915B (en) * | 2021-05-14 | 2022-07-08 | 北京百度网讯科技有限公司 | Processing method, device, equipment, storage medium and program for calling information |
Also Published As
Publication number | Publication date |
---|---|
CN111813465B (en) | 2023-11-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109634598B (en) | Page display method, device, equipment and storage medium | |
CN111813465B (en) | Information acquisition method, device, medium and equipment | |
CN110865898B (en) | Method, device, medium and equipment for converging crash call stack | |
CN110502357B (en) | Stack backtracking method, device, medium and equipment | |
CN111813641B (en) | Method, device, medium and equipment for collecting crash information | |
CN110489179B (en) | Method, device, medium and equipment for acquiring call stack frame function signature | |
CN110471709B (en) | Method, device, medium and electronic equipment for accelerating webpage opening speed | |
CN110764941B (en) | Method, device, medium and equipment for acquiring call stack frame instruction offset | |
CN109446025B (en) | Operation behavior playback method and device, electronic equipment and readable medium | |
CN110070593B (en) | Method, device, equipment and medium for displaying picture preview information | |
CN111258998A (en) | Data verification method, device, medium and electronic equipment | |
CN111026400A (en) | Method and device for analyzing service data stream | |
CN111198999A (en) | Method, device, medium and electronic equipment for loading pictures of webpage end | |
CN110865852A (en) | Webpage component loading method and device, electronic equipment and storage medium | |
CN107301220B (en) | Method, device and equipment for data driving view and storage medium | |
CN109697034B (en) | Data writing method and device, electronic equipment and storage medium | |
CN115209215B (en) | Video processing method, device and equipment | |
CN112954453B (en) | Video dubbing method and device, storage medium and electronic equipment | |
CN110069186B (en) | Method and equipment for displaying operation interface of application | |
CN109857503B (en) | Page interaction effect self-adaption method and device and electronic equipment | |
CN110717126A (en) | Page browsing method and device, electronic equipment and computer readable storage medium | |
CN114461214A (en) | Page display method and device, electronic equipment and storage medium | |
CN109284350B (en) | Method and device for updating search content, storage medium and electronic equipment | |
CN111813667A (en) | Method, device, medium and equipment for collecting application running track | |
CN112506592A (en) | Method, device, equipment and storage medium for determining page loading duration |
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 |