[go: up one dir, main page]

CN111813465B - Information acquisition method, device, medium and equipment - Google Patents

Information acquisition method, device, medium and equipment Download PDF

Info

Publication number
CN111813465B
CN111813465B CN202010565709.1A CN202010565709A CN111813465B CN 111813465 B CN111813465 B CN 111813465B CN 202010565709 A CN202010565709 A CN 202010565709A CN 111813465 B CN111813465 B CN 111813465B
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.)
Active
Application number
CN202010565709.1A
Other languages
Chinese (zh)
Other versions
CN111813465A (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 CN202010565709.1A priority Critical patent/CN111813465B/en
Publication of CN111813465A publication Critical patent/CN111813465A/en
Application granted granted Critical
Publication of CN111813465B publication Critical patent/CN111813465B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/4488Object-oriented
    • G06F9/449Object-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)
  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Abstract

The present disclosure provides a method, apparatus, medium and device for information acquisition, where the method includes: 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 buffer area based on the first stack storage object; the stack frame information buffer area is used for storing stack frame information corresponding to a main thread call stack in the history operation process in the form of a key value pair. The method and the device can improve the speed of information acquisition, quickly acquire the call stack information of the main thread, and improve the execution efficiency of the program.

Description

Information acquisition method, device, medium and equipment
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 information acquisition.
Background
In the running process of each application program of the android system, a call stack of each thread is required to be continuously called, corresponding tasks are executed by acquiring information of a call stack frame, the stack can record function call (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 needs to be used to analyze which method specifically causes the blocking.
The existing method for acquiring the android main Thread call stack is generally to call a currentThread method of a Thread class to acquire a current Thread object, and then call a getStacktrace method to acquire the call stack. The calling method is long in time consumption, and particularly when the calling stack is deeper, the information of the calling stack is difficult to acquire in time, so that the efficiency of running of a program, fault detection and the like is reduced.
BRIEF SUMMARY OF THE PRESENT DISCLOSURE
The present disclosure aims to provide a method, an apparatus, a medium and a device for information acquisition, which can solve at least one technical problem mentioned above. The specific scheme is as follows:
according to a specific embodiment 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 buffer area based on the first stack storage object; the stack frame information buffer area is used for storing stack frame information corresponding to a main thread call stack in the history operation process in the form of a key value pair.
Optionally, the obtaining, 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 from a stack frame information buffer area 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 more than or equal to 0 and less than or equal to N-1, and N is the number of stack frames;
and traversing the pre-created call stack object in the stack frame information buffer area 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 marking the stack frame information corresponding to the searched stack frame identification with the index of i as first stack frame information.
Optionally, the 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:
the first stack storage object is strongly converted 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 a first half section of the first integer array as an object pointer, and acquiring a 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 a class name.
Optionally, after marking the 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 unobscured stack frame based on the call stack object, and marking the unobscured 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 the unqueried stack frame, marking the unqueried 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 queried;
and calling the abnormal class object through a second stack function, acquiring an unoccupied stack frame, and marking the unoccupied stack frame as second stack frame information.
Optionally, the creating an abnormal class object, where the abnormal class object includes unqueried stack frame information, includes:
constructing a second integer array, wherein the size of the second integer array is 2*M, and M represents the number of unqueried stack frames; respectively inputting an object pointer and an instruction offset value of an unoccupied stack frame into a first half section and a 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 into the 0 index position of the second object array, and inputting the class name which is not queried into the rest part of the second object array;
and creating an abnormal class object, wherein the abnormal class object comprises a second stack storage object, and setting the second stack storage object reflection as the second object array.
Optionally, before the calling the first stack function, the method includes:
and analyzing the virtual machine layer standard file, obtaining a first stack function address, and calling the first stack function through the first stack function address.
According to a second aspect of the specific embodiments of the present disclosure, the present disclosure provides an information acquisition apparatus, including:
the calling unit is used for calling a first stack function and acquiring a first stack storage object returned by the first stack function;
the acquisition unit 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 buffer area based on the first stack storage object; the stack frame information buffer area is used for storing stack frame information corresponding to a main thread call stack in the history operation process in the form of a key value pair.
According to a third aspect of the present disclosure, there is provided a computer readable storage medium having stored thereon a computer program which when executed by a processor implements a method as claimed in any one of the above.
According to a fourth aspect of the present disclosure, there is provided an electronic device comprising: one or more processors; storage means for storing one or more programs that, when executed by the one or more processors, cause the one or more processors to implement the method of any of the preceding claims.
Compared with the prior art, the scheme of the embodiment of the disclosure has at least the following beneficial effects: when the method acquires the call stack, firstly, a system function is called to acquire the active layer representation of the call stack, then, the stack frame information is searched in a cache, if the corresponding stack frame information exists in the cache, the information is saved, the stack frame information is acquired through a system in a way of constructing a through object for the stack frame which is not hit in the cache, and the cache is built for each acquired stack frame information, so that the stack frame which is not hit in the cache is only required to be converted into a character string, the information acquisition speed is improved, the call stack information of a main thread is acquired rapidly, 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 disclosure and together with the description, serve to explain the principles of the disclosure. It will be apparent to those of ordinary skill in the art that the drawings in the following description are merely examples of the disclosure and that other drawings may be derived from them without undue effort. In the drawings:
FIG. 1 illustrates a flow chart of an information acquisition method according to an embodiment of the present disclosure;
FIG. 2 illustrates a data structure diagram of an object array according to an embodiment of the present disclosure;
FIG. 3 illustrates a diagram of an get call stack apparatus architecture according to an embodiment of the present disclosure;
FIG. 4 illustrates a schematic diagram of a processing unit architecture according to an embodiment of the present disclosure;
fig. 5 shows a schematic diagram of an electronic device connection structure according to an embodiment of the present disclosure.
Detailed Description
For the purpose of promoting an understanding of the principles and advantages of the disclosure, reference will now be made in detail to the drawings, in which it is apparent that the embodiments described are only some, but not all embodiments of the disclosure. Based on the embodiments in this disclosure, all other embodiments that a person of ordinary skill in the art would obtain without making any inventive effort are within the scope of protection of this disclosure.
The terminology used in the embodiments of the disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. As used in this disclosure of 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, the "plurality" generally includes at least two.
It should be understood that the term "and/or" as used herein is merely one relationship describing the association of the associated objects, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
It should be understood that although the terms first, second, third, etc. may be used to describe … … in the presently disclosed embodiments, these … … should not be limited to these terms. These terms are only used to distinguish … …. For example, the first … … may also be referred to as the second … …, and similarly the second … … may also be referred to as the first … …, without departing from the scope of the disclosed embodiments.
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 phrase "if determined" or "if detected (stated condition or event)" may be interpreted as "when determined" or "in response to determination" or "when detected (stated condition or event)" or "in response to detection (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 product 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 product or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a commodity or device comprising such element.
Alternative embodiments of the present disclosure are described in detail below with reference to the drawings.
As shown in fig. 1, according to a specific embodiment of the present disclosure, the present disclosure provides a method for obtaining information, including the following method steps:
step S102: and 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: and analyzing the virtual machine layer standard file, obtaining a first stack function address, and calling the first stack function through the first stack function address.
For an operating program developed by an android system, a native layer developed based on an editing language such as C or c++, an art virtual machine layer operating on the native layer, and a Java assembly layer operating on the art virtual machine layer are generally included. For the program development and execution process, the Java layer can call the executable functions of the original layer to execute related tasks through the virtual machine layer.
In this embodiment, when the application program is started, the address of the stack function createinteralstack trace needs to be obtained by analyzing the standard ELF file, i.e., libart. The ELF file is a file in a binary file, an executable file, an object code, a shared library and a core dump format, and consists of 4 parts, namely an ELF header (ELF header), a program header table (Program header table), a Section (Section) and a Section header table (Section header table).
When a call stack of a main thread needs to be acquired in the program running process, a stack function CreateINTERNall StackTrace is called first, and returns a stack storage object backtrace which stores all information of the call stack of the main thread and is an active 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 buffer area based on the first stack storage object; the stack frame information buffer area is used for storing stack frame information corresponding to a main thread call stack in the history operation process in the form of a key value pair.
As one embodiment, the obtaining, based on the first stack storage object, stack frame information corresponding to each stack frame identifier of the main thread call stack in the first stack storage object from a stack frame information buffer area includes the following substeps:
step S104-1: and carrying out 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 the index of i, wherein i is more 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: the first stack storage object is strongly converted 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 a first half section of the first integer array as an object pointer, and acquiring a 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 a class name. Wherein the length of the first object array is n+1, where N represents the total number of stack frames, and the length of the first integer array is 2*N.
In the specific implementation mode, the stack storage Object backtrace is strongly converted into an Object array of an Object [ ] type, and is recorded as a backtrace; as shown in fig. 2, the first element first of the object array backtraceArr is taken; the first element first is strongly converted into integer arrays of the int [ ] type (in the case of 32-bit operation) or the long [ ] type (in the case of 64-bit operation), and is marked as first IL; the data of the second half section of the integer array first IL is the instruction offset value dexpc of all stack frames, the instruction offset value dexpc corresponds to the stack frames one by one, and the first half section of the integer array first IL is an object pointer Artmethod; the remainder of the object array backtraceArr, except for the first element first, is Class name Class for 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 firstIL is 2*N, and when the information of the stack frame (0 < =i < N) with index i needs to be fetched, the stack frame is determined by the following three parts together: the first part is the instruction offset value dexpc represented by the object pointer ArtMethod, firstIL [ i+n ] represented by first il [ i ], and the Class name Class represented by backtraceArr [ i+1 ].
Step S104-2: and traversing the pre-created call stack object in the stack frame information buffer area 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 marking the stack frame information corresponding to the searched stack frame identification with the index of i as first stack frame information.
The method comprises the steps of creating a call stack object in advance, for example, creating a call stack object mymap, wherein parameters key and value in the call stack object mymap are in the form of character strings.
Firstly, fetching from a cache: i traverses from 0 to N-1, for each traversal: and inquiring corresponding detailed stack frame information in a call stack object mymap created by taking a character string consisting of first IL [ i ] +first IL [ i+N ] +backtraceAri as a first character string parameter key, if the corresponding stack frame information is found, recording the stack frame information, and marking a stack frame with an index of i as a hit cache. Part of stack frame information is firstly taken out from the cache, the part of stack frame information can be rapidly acquired, time is saved for acquiring all stack frame information, and efficiency is improved.
Step S104-3: and acquiring an unobscured stack frame based on the call stack object, and marking the unobscured 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 obtaining the stack frame that is not queried, marking the stack frame that is not queried as the second stack frame information, includes the following sub steps:
step S104-3-1: an exception class object is created, the exception class object comprising unrequired stack frame information.
The method specifically comprises the following steps: constructing a second integer array, wherein the size of the second integer array is 2*M, and M represents the number of unqueried stack frames; respectively inputting an object pointer and an instruction offset value of an unoccupied stack frame into a first half section and a 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 into the 0 index position of the second object array, and inputting the class name which is not queried into the rest part of the second object array; and creating an abnormal class object, wherein the abnormal class object comprises a second stack storage object, and setting the second stack storage object reflection as the second object array.
As one of the specific embodiments, the method comprises the following steps:
first, building a second integer array, for example, building an integer array first il2 of either the int [ ] type (in the case of 32-bit operation) or the long [ ] type (in the case of 64-bit operation), the size of which can be recorded as 2*M, where M represents the number of uninquired stack frames; and respectively inputting an object pointer Artmethod and an instruction offset value dexpc of the unqueried stack frame into the first half section and the second half section of the second integer array.
And second, constructing a second Object array, for example, constructing an Object array backtracking Arr2 of an Object [ ] type, wherein the size of the second Object array is M+1, inputting the second integer array first IL2 into the 0 index of the second Object array backtracking Arr2, and inputting the Class name Class which is not queried into the rest of the second Object array backtracking Arr2.
Thirdly, creating an exception class object capable, wherein the exception class object capable comprises a second stack storage object backtrace2, and setting the second stack storage object backtrace2 reflection as the second object array backtrace Arr2.
Step S104-3-2: and calling the abnormal class object through a second stack function, acquiring an unoccupied stack frame, and marking the unoccupied stack frame as second stack frame information.
Specifically, the unqueried stack frame information can be obtained by calling a second stack function getStackTrace of the exception object Throwable, and the unqueried stack frame 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 in the cache to form complete main thread call stack information.
When the method acquires the call stack, firstly, a system function is called to acquire the active layer representation of the call stack, then, the stack frame information is searched in a cache, if the corresponding stack frame information exists in the cache, the information is saved, the stack frame information is acquired through a system in a way of constructing a through object for the stack frame which is not hit in the cache, and the cache is built for each acquired stack frame information, so that the stack frame which is not hit in the cache is only required to be converted into a character string, the information acquisition speed is improved, the call stack information of a main thread is acquired rapidly, and the execution efficiency of a program is improved.
In addition, the disclosure further provides an embodiment of the apparatus adapted to the above embodiment, so as to implement the method steps described in the above embodiment, and the explanation based on the meaning of the same names is the same as that of the above embodiment, which has the same technical effects as those of the above embodiment, and will not be repeated herein.
As shown in fig. 3, according to a specific embodiment of the present disclosure, the present disclosure provides an apparatus for information acquisition, including:
and the calling unit 302 is 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 corresponding to each stack frame identifier of the main thread call stack in the first stack storage object is obtained from a stack frame information buffer area based on the first stack storage object; the stack frame information buffer area is used for storing stack frame information corresponding to a main thread call stack in the history operation process in the form of a key value pair.
As one of the embodiments, as shown in fig. 4, the acquisition unit 304 includes:
processing unit 3041: and the method is used for carrying out 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 the index of i, wherein i is more than or equal to 0 and less than or equal to N-1, and N is the number of stack frames.
Optionally, the processing unit 3041 is specifically configured to: the first stack storage object is strongly converted 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 a first half section of the first integer array as an object pointer, and acquiring a 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 a class name. Wherein the length of the first object array is n+1, where N represents the total number of stack frames, and the length of the first integer array is 2*N.
The traversing unit 3042: and traversing the pre-created call stack object in the stack frame information buffer area 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 marking the stack frame information corresponding to the searched stack frame identification with the index of i as first stack frame information.
Marking unit 3043: and the method is used for acquiring an unobscured stack frame based on the call stack object, and marking the unobscured 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 obtaining the unqueried stack frame, marking the unqueried stack frame as second stack frame information includes: an exception class object is created, the exception class object comprising unrequired stack frame information. And calling the abnormal class object through a second stack function, acquiring an unoccupied stack frame, and marking the unoccupied stack frame as second stack frame information.
The creating an abnormal class object, where the abnormal class object includes unqueried stack frame information, includes: constructing a second integer array, wherein the size of the second integer array is 2*M, and M represents the number of unqueried stack frames; respectively inputting an object pointer and an instruction offset value of an unoccupied stack frame into a first half section and a 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 into the 0 index position of the second object array, and inputting the class name which is not queried into the rest part of the second object array; and creating an abnormal class object, wherein the abnormal class object comprises a second stack storage object, and setting the second stack storage object reflection as the second object array.
When the device acquires a call stack, firstly, a system function is called to obtain a native layer representation of the call stack, then, the stack frame information is searched in a cache, if the corresponding stack frame information exists in the cache, the information is saved, the stack frame information is acquired through a system in a way of constructing a through object for the stack frame which is not hit in the cache, and the cache is built for each acquired stack frame information, so that the stack frame which is not hit in the cache is only required to be converted into a character string, the information acquisition speed is improved, 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 enable the at least one processor to perform the method steps described in the embodiments above.
The disclosed embodiments provide a non-transitory computer storage medium storing computer executable instructions that perform the method steps described in the embodiments above.
Referring now to fig. 5, a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure is shown. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 5 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 5, the electronic device may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 501, which 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 required for the operation of the electronic device are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 505. An input/output (I/O) interface 505 is also connected to bus 505.
In general, the following devices may be connected to the I/O interface 505: input devices 506 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 505 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 508 including, for example, magnetic tape, hard disk, etc.; 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 shows an electronic device having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to 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 shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 505, or installed from storage means 508, or installed from ROM 502. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 501.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples 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 context of this 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 the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. 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 of the foregoing. 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, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
Computer program code for carrying out operations of the present disclosure may be written in 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 kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts 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 involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Wherein the names of the units do not constitute a limitation of the units themselves in some cases.

Claims (7)

1. An information acquisition method, characterized by 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 buffer area based on the first stack storage object; the stack frame information buffer area is used for storing stack frame information corresponding to a main thread call stack in the history operation process in the form of a key value pair;
the obtaining, 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 from a stack frame information buffer area 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 more than or equal to 0 and less than or equal to N-1, and N is the number of stack frames;
traversing a pre-created call stack object in a stack frame information buffer area by taking a character string consisting of the object pointer with the index of i, an instruction offset value and a class name as a character string parameter, and marking stack frame information corresponding to the queried stack frame with the index of i as first stack frame information;
for an unoccupied stack frame, creating an abnormal class object, wherein the abnormal class object comprises unoccupied stack frame information; and calling the abnormal class object through a second stack function, acquiring an unobscured stack frame, marking the unobscured stack frame as second stack frame information, and forming stack frame information corresponding to the main thread call stack by the second stack frame information and the first stack frame information.
2. The method of claim 1, wherein the performing data processing on the first stack memory object to obtain an object pointer, an instruction offset value, and a class name for the first stack memory object with index i comprises:
the first stack storage object is strongly converted 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 a first half section of the first integer array as an object pointer, and acquiring a 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 a class name.
3. The method of claim 1, wherein the creating an exception class object, the exception class object comprising unqueried stack frame information, comprises:
constructing a second integer array, wherein the size of the second integer array is 2*M, and M represents the number of unqueried stack frames; respectively inputting an object pointer and an instruction offset value of an unoccupied stack frame into a first half section and a 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 into the 0 index position of the second object array, and inputting the class name which is not queried into the rest part of the second object array;
and creating an abnormal class object, wherein the abnormal class object comprises a second stack storage object, and setting the second stack storage object reflection as the second object array.
4. The method of claim 1, wherein before the calling the first stack function, comprising:
and analyzing the virtual machine layer standard file, obtaining a first stack function address, and calling the first stack function through the first stack function address.
5. An information acquisition apparatus, characterized by comprising:
the calling unit is used for calling a first stack function and acquiring a first stack storage object returned by the first stack function;
the acquisition unit 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 buffer area based on the first stack storage object; the stack frame information buffer area is used for storing stack frame information corresponding to a main thread call stack in the history operation process in the form of a key value pair;
the acquisition unit includes:
the processing unit is used for carrying out 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 the index of i, wherein i is more than or equal to 0 and less than or equal to N-1, and N is the number of stack frames;
the traversing unit is used for traversing the pre-created call stack object in the stack frame information buffer area by taking a character string formed by the object pointer with the index of i, the instruction offset value and the class name as a character string parameter, and marking stack frame information corresponding to the searched stack frame identification with the index of i as first stack frame information;
the marking unit is used for creating an abnormal class object aiming at the stack frame which is not queried, wherein the abnormal class object comprises stack frame information which is not queried; and calling the abnormal class object through a second stack function, acquiring an unobscured stack frame, marking the unobscured stack frame as second stack frame information, and forming stack frame information corresponding to the main thread call stack by the second stack frame information and the first stack frame information.
6. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any one of claims 1 to 4.
7. 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 implement the method of any of claims 1 to 4.
CN202010565709.1A 2020-06-19 2020-06-19 Information acquisition method, device, medium and equipment Active CN111813465B (en)

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 CN111813465A (en) 2020-10-23
CN111813465B true 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)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112925717B (en) * 2021-03-22 2024-03-12 北京字节跳动网络技术有限公司 Method, apparatus, device and medium for determining object of call stack frame
CN112905381B (en) 2021-03-22 2022-12-06 北京字节跳动网络技术有限公司 Method, device, equipment and medium for acquiring stack frame information in call stack
CN113238915B (en) * 2021-05-14 2022-07-08 北京百度网讯科技有限公司 Processing method, device, device, storage medium and program for calling information
CN114237624B (en) * 2021-12-21 2024-12-20 建信金融科技有限责任公司 Error handling method, device, equipment, medium and product based on Go language
CN120805150A (en) * 2025-09-15 2025-10-17 杭州默安科技有限公司 Vulnerability characteristic recognition method, device, equipment and medium based on abnormal object

Citations (6)

* Cited by examiner, † Cited by third party
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

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10997057B2 (en) * 2018-11-15 2021-05-04 International Business Machines Corporation Debugging asynchronous functions

Patent Citations (6)

* Cited by examiner, † Cited by third party
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

Also Published As

Publication number Publication date
CN111813465A (en) 2020-10-23

Similar Documents

Publication Publication Date Title
CN111813465B (en) Information acquisition method, device, medium and equipment
CN111274760B (en) Rich text data processing method and device, electronic equipment and computer storage medium
CN109634598B (en) Page display method, device, equipment and storage medium
CN110489345B (en) Crash aggregation method, device, medium and equipment
CN111198859B (en) Data processing method, device, electronic equipment and computer readable storage medium
CN111813641B (en) Method, device, medium and equipment for collecting crash information
CN110865898B (en) Method, device, medium and equipment for converging crash call stack
CN109446025B (en) Operation behavior playback method and device, electronic equipment and readable medium
CN110471709B (en) Method, device, medium and electronic equipment for accelerating webpage opening speed
CN110502357A (en) A kind of stack retrogressive method, device, medium and equipment
CN111198999B (en) Picture loading method and device for webpage end, medium and electronic equipment
CN111258998A (en) Data verification method, device, medium and electronic equipment
CN111026400A (en) Method and device for analyzing service data stream
CN111045926A (en) Application program jamming detection method, device, medium and electronic equipment
CN113094286B (en) Page test method and device, storage medium and electronic equipment
CN112379967B (en) Simulator detection method, device, equipment and medium
CN111857720B (en) User interface state information generation method and device, electronic equipment and medium
CN112486494A (en) File generation method and device, electronic equipment and computer readable storage medium
CN110069186B (en) Method and device for displaying operation interface of application
CN110717126A (en) Page browsing method and device, electronic equipment and computer readable storage medium
CN110908860B (en) Java thread acquisition method and device, medium and electronic equipment
CN112256346A (en) Control display method, device and electronic device
CN114647411B (en) Programming interface loading method, device, electronic device and storage medium
CN111176957A (en) Log browsing method and device including timely search and electronic equipment
US20240184973A1 (en) Method and apparatus for generating document tag, and terminal and storage medium

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