WO2022199331A1 - 用于获取调用栈中栈帧信息的方法、装置、设备和介质 - Google Patents
用于获取调用栈中栈帧信息的方法、装置、设备和介质 Download PDFInfo
- Publication number
- WO2022199331A1 WO2022199331A1 PCT/CN2022/078365 CN2022078365W WO2022199331A1 WO 2022199331 A1 WO2022199331 A1 WO 2022199331A1 CN 2022078365 W CN2022078365 W CN 2022078365W WO 2022199331 A1 WO2022199331 A1 WO 2022199331A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- memory area
- area
- stack
- stack frame
- address
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 158
- 230000008569 process Effects 0.000 claims abstract description 27
- 230000002159 abnormal effect Effects 0.000 claims abstract description 6
- 230000006870 function Effects 0.000 claims description 33
- 238000004590 computer program Methods 0.000 claims description 20
- 230000005856 abnormality Effects 0.000 claims description 4
- 238000010586 diagram Methods 0.000 description 6
- 238000005516 engineering process Methods 0.000 description 3
- 238000003491 array Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000006978 adaptation Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000008014 freezing Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000000717 retained effect Effects 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
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/006—Identification
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/0703—Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
- G06F11/0706—Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment
- G06F11/0718—Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment in an object-oriented system
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/0703—Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
- G06F11/0766—Error or fault reporting or storing
- G06F11/0787—Storage of error reports, e.g. persistent data storage, storage using memory protection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/0703—Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
- G06F11/079—Root cause analysis, i.e. error or fault diagnosis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2201/00—Indexing scheme relating to error detection, to error correction, and to monitoring
- G06F2201/87—Monitoring of transactions
Definitions
- the present disclosure relates to the field of computer technologies, and in particular, to a method, apparatus, device and medium for acquiring stack frame information in a call stack.
- the method pointer such as the ArtMethod pointer
- the instruction offset value (DexPc) included in each stack frame can be obtained, but the detailed information describing the current method cannot be directly obtained, such as the method name and Source line number and other information.
- the method (such as ArtMethod) pointer can be used as a parameter to call the PrettyMethod function to obtain the string description information of the corresponding method; on the other hand, it can be obtained through some underlying technologies.
- the dex_file information corresponding to the method and then based on the dex_file information to obtain the class name, method name and other information of the method.
- the embodiments of the present disclosure provide a method, apparatus, device and medium for acquiring stack frame information in a call stack.
- an embodiment of the present disclosure provides a method for acquiring stack frame information in a call stack, including:
- each area unit of the call stack to be processed includes a method pointer and an instruction offset value corresponding to the method pointer.
- the total number of area units is N;
- the code segment corresponding to the stack frame information acquisition function module getStackTrace is executed to acquire information of each stack frame in the to-be-processed call stack.
- an embodiment of the present disclosure further provides an apparatus for acquiring stack frame information in a call stack, including:
- a call stack acquisition module used to acquire an abnormal pending call stack during the running of the program; wherein, each area unit of the pending call stack includes a method pointer and an instruction offset value corresponding to the method pointer, The total number of area units of the to-be-processed call stack is N;
- the first memory application module is used to apply for a first memory area; wherein, the first half area unit of the first memory area is used to store the method pointer, and the second half area unit of the first memory area is used to store The instruction offset value corresponding to the method pointer, the total number of area units of the first memory area is 2N;
- a first address obtaining module configured to obtain the address of the first memory area
- a second memory application module configured to apply for a second memory area, and store the address of the first memory area in the first area unit in the second memory area; wherein, the area of the second memory area The total number of units is N+1;
- a second address obtaining module configured to obtain the address of the second memory area
- a third memory application module configured to apply for a third memory area, obtain a target storage area in the third memory area, and store the address of the second memory area in the target storage area;
- the stack frame information acquisition module is used to execute the code segment corresponding to the stack frame information acquisition function module getStackTrace based on the address of the second memory area stored in the target storage area, and acquire the information of each stack frame in the to-be-processed call stack. information.
- embodiments of the present disclosure further provide an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the electronic device is made to The device implements any of the methods for acquiring stack frame information in the call stack provided in the embodiments of the present disclosure.
- an embodiment of the present disclosure further provides a computer-readable storage medium, where a computer program is stored in the storage medium, and when the computer program is executed by a computing device, the computing device enables the computing device to implement the embodiment of the present disclosure Any of the provided methods for obtaining stack frame information in a call stack.
- the method pointer in the call stack to be processed that has an exception during the running process of the program is stored in the first half area unit of the first memory area, and the instruction corresponding to the method pointer is offset.
- the shift value is stored in the second half area unit of the first memory area, then the address of the first memory area is stored in the first area unit in the second memory area of the application, and then the address of the second memory area is stored in the application.
- the target storage area in the third memory area of The code segment corresponding to the information acquisition function module getStackTrace acquires the information of each stack frame in the call stack to be processed, which solves the problem that the detailed information of the stack frame cannot be stably acquired in the existing solution, and realizes the stable acquisition of the detailed information of the stack frame. , and reduces the complexity of obtaining the detailed information of the stack frame, and has high compatibility with different system versions. By acquiring the detailed information of the stack frame, it is helpful to locate the exception in the running process of the program conveniently and efficiently, and the efficiency of solving the program exception is improved.
- FIG. 1 is a flowchart of a method for acquiring stack frame information in a call stack provided by an embodiment of the present disclosure
- FIG. 2 is a flowchart of another method for acquiring stack frame information in a call stack provided by an embodiment of the present disclosure
- FIG. 3 is a schematic diagram of the relationship between various arrays in a process of acquiring stack frame information according to an embodiment of the present disclosure
- FIG. 4 is a schematic structural diagram of an apparatus for acquiring stack frame information in a call stack according to an embodiment of the present disclosure
- FIG. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
- FIG. 1 is a flowchart of a method for acquiring stack frame information in a call stack provided by an embodiment of the present disclosure, the method may be executed by an apparatus for acquiring stack frame information in a call stack, and the apparatus may use software and/or Or hardware implementation, and can be integrated on electronic devices with computing capabilities, such as mobile terminals, notebooks, computers, etc.
- the method for acquiring stack frame information in a call stack may include:
- each area unit of the call stack to be processed includes a method pointer and an instruction offset value corresponding to the method pointer, and the total number of area units of the call stack to be processed The number is N.
- the program running process mentioned in the embodiments of the present disclosure may be the running process of at least one application program on the electronic device, and the call stack that is abnormal in the program running process may be obtained by using the call stack acquisition method available in the existing solution, such as program crash. , the call stack generated in the process of program freezing, etc., as the subsequent processing object.
- the call stack can be represented in the form of an array on the bottom layer of the code.
- the element positions in the array correspond to the area units of the call stack.
- the total number of area units of the call stack, N is the length of the array, N, and N is an integer.
- Each element consists of a method pointer ArtMethod (or called ArtMethod pointer) and an instruction offset value DexPc, and there is a one-to-one correspondence between the method pointer and the instruction offset value.
- obtain call stacks with exceptions during program execution including:
- the repeated call stacks in multiple call stacks are determined; that is, the call stacks with the same method pointer and corresponding instruction offset value belong to the repeated call stacks;
- the multiple call stacks are deduplicated based on the repeated call stacks to obtain the to-be-processed call stacks.
- the number of call stacks to be processed can be reduced, the efficiency of acquiring stack frame information can be improved, and the accuracy of the acquired stack frame information will not be affected.
- S102 apply for a first memory area; wherein, the first half area unit of the first memory area is used to store the method pointer, the second half area unit of the first memory area is used to store the instruction offset value corresponding to the method pointer, the first The total number of area units in the memory area is 2N.
- the method pointer can be used to obtain at least one of the method name of the stack frame, the class name of the stack frame method, and the source code file name corresponding to the stack frame;
- the instruction offset value can be used to obtain the source code line number corresponding to the stack frame.
- applying for the first memory area includes:
- construct the code for applying for the first memory area for the aforementioned first array For example, the new int[] command or the new long[] command can be used to realize the creation of the first memory belonging to the integer or long integer.
- the type of the first array is an integer; for a 64-bit system, the type of the first array is a long integer.
- the order of appearance of the method pointer or instruction offset value in the call stack to be processed is the same as the order of appearance in the first memory area, that is, the method pointer or instruction offset value is in the
- the pending call stacks appear in the same order as they appear in the first array.
- the address acquisition of the memory region can be implemented based on any available existing address acquisition methods.
- the address of the first memory area can be used to obtain the storage content in the first memory area.
- S104 apply for a second memory area, and store the address of the first memory area into the first area unit in the second memory area; wherein, the total number of area units in the second memory area is N+1.
- the address of the first memory area is stored in the second memory area
- the storage content of other remaining area units in the second memory area is not specifically limited in this embodiment of the present disclosure, for example, the default value of null may be retained.
- the total number of area units in the second memory area needs to be N+1.
- applying for the second memory area includes: applying for the second memory area for the second array under the object base class Object.
- build the code for applying for the second memory area for the second array under the object base class Object that is, for the java program, the second array belongs to the Object[] type), for example, you can use new Object[]
- the command implements the creation of a second array under the object base class Object; wherein, the elements of the second array are respectively stored in the area units of the second memory area.
- the execution sequence of each operation step is not strictly limited.
- the address of the first memory area may be obtained first, and then the second memory area may be applied for, or the second memory area may be applied for first, and then the address of the first memory area may be obtained, and of course, the first memory area may be obtained.
- the address of the area and the application for the second memory area may also be executed at the same time, which is not specifically limited in this embodiment of the present disclosure.
- the address of the second memory area can be used to obtain the storage content in the second memory area.
- S106 apply for a third memory area, acquire a target storage area in the third memory area, and store the address of the second memory area in the target storage area.
- the target storage area in the third memory area may be determined according to the execution requirement of the stack frame information acquisition function getStackTrace.
- applying for the third memory area includes: applying for the third memory area for the target object under the exception parent class Throwable.
- build the code for applying for the third memory area for the target object under the exception parent class Throwable For example, you can use the new Throwable() command to create the target object under the exception parent class Throwable.
- the target object It can be exemplarily represented by thr.
- the target storage area in the third memory area may be acquired, and the address of the second memory area is stored in the target storage area. S107.
- execute a code segment corresponding to the stack frame information acquisition function module getStackTrace to acquire information of each stack frame in the call stack to be processed.
- the address of the first memory area stored in the first area unit in the second memory area can be obtained through the address of the second memory area, and then the address of the first memory area can be obtained through the address of the first memory area.
- the method pointer stored in the first memory area and the instruction offset value corresponding to the method pointer are obtained, and then the method name of the stack frame, the class name of the stack frame method, and the source code file name corresponding to the stack frame can be obtained based on the method pointer.
- At least one of the methods is to obtain the source code line number corresponding to the stack frame based on the instruction offset value corresponding to the method pointer.
- each stack frame mentioned in the embodiments of the present disclosure may include at least one of the following: the method name of the stack frame, the class name of the stack frame method, the source code file name corresponding to the stack frame, and the source code line number corresponding to the stack frame.
- an initial member (backtrace member) of the target object is created at the same time, and the target storage area is used to store the backtrace member.
- the getStackTrace function in the code segment corresponding to the stack frame information acquisition function module getStackTrace belongs to the function of the target object under the exception parent class Throwable.
- the stack frame information to obtain the code segment corresponding to the function module getStackTrace, and obtain the information of each stack frame in the call stack to be processed, including:
- the function getStackTrace is a system function. During the execution of the function, its return value is a storage address pointing to a specific array, through which the required stack frame information can be obtained. Exemplarily, the storage address points to the stack frame information array StackTraceElement, and each element in the stack frame information array corresponds to information of different stack frames.
- StackTraceElement[]elements thr.getStackTrace();//thr is used to refer to the target object under the exception parent class Throwable; elements as an array name under the StackTraceElement[] type, here is only for example, the array can be flexibly determined name
- the following describes the embodiments of the present disclosure by using exemplary program codes from the perspective of program writing, but should not be construed as specific limitations on the embodiments of the present disclosure.
- N of the call stack to be processed is 2 as an example
- an exemplary illustration is made, that is, the call stack to be processed includes two groups of elements: method pointer method1 and instruction offset value dexpc1, method pointer method2 and Instruction offset dexpc2.
- the program code example is as follows:
- the method provided by the embodiment of the present disclosure may further include: sending the information of each stack frame to the server; wherein, the server is used to analyze the abnormality in the running process of the program based on the information of each stack frame, so as to improve the resolution of the abnormality of the program s efficiency.
- the server may communicate with a plurality of electronic devices for executing the technical solutions of the embodiments of the present disclosure. Locate exceptions during application operation.
- the method pointer in the call stack to be processed is stored in the first half area unit of the first memory area, and the instruction offset value corresponding to the method pointer is stored in the first memory area.
- the second half area unit of the area, and then the address of the first memory area is stored in the first area unit in the second memory area of the application, and then the address of the second memory area is stored in the third memory area of the application.
- the target storage area so as to realize the controllable storage of the method pointer and the corresponding instruction offset value in the call stack to be processed, and finally, based on the address of the second memory area stored in the target storage area, execute the stack frame information to obtain the corresponding function module getStackTrace
- the code segment obtains the information of each stack frame in the call stack to be processed, solves the problem that the detailed information of the stack frame cannot be stably obtained in the existing solution, realizes the stable acquisition of the detailed information of the stack frame, and reduces the detailed information of the stack frame
- the complexity of information acquisition has high compatibility with different system versions. By acquiring the detailed information of the stack frame, it is helpful to locate the exception in the running process of the program conveniently and efficiently, and the efficiency of solving the program exception is improved.
- FIG. 2 is a flowchart of another method for acquiring stack frame information in a call stack provided by an embodiment of the present disclosure, which is used to illustrate the embodiment of the present disclosure and should not be construed as a specific limitation to the embodiment of the present disclosure. Specifically, FIG. 2 exemplarily explains the embodiment of the present disclosure from the perspective of the execution flow of a computer program.
- an array which can be exemplarily defined as rawArr in the programming phase, Each element of the array consists of an ArtMethod pointer and a corresponding instruction offset value DexPc, the length of the array is recorded as N; create an int or long array with a length of 2N (int type in the case of 32-bit system, 64-bit system In the case of long type), the array can be exemplarily defined in the programming phase to be represented by firstIL;
- the embodiments of the present disclosure achieve stable acquisition of detailed information of stack frames, reduce the complexity of acquiring detailed information of stack frames, and have high compatibility with different system versions.
- FIG. 4 is a schematic structural diagram of an apparatus for acquiring stack frame information in a call stack provided by an embodiment of the present disclosure
- the apparatus may be implemented by software and/or hardware, and may be integrated on any electronic device with computing capability, For example, mobile terminals, notebooks, computers, etc.
- an apparatus 400 for acquiring stack frame information in a call stack may include a call stack acquiring module 401 , a first memory application module 402 , a first address acquiring module 403 , and a second memory application module 401 .
- Module 404, second address acquisition module 405, third memory application module 406 and stack frame information acquisition module 407 wherein:
- the call stack obtaining module 401 is used to obtain the call stack to be processed that has an exception in the running process of the program; wherein, each area unit of the call stack to be processed includes a method pointer and an instruction offset value corresponding to the method pointer, and the call stack to be processed is called The total number of area units of the stack is N;
- the first memory application module 402 is used to apply for a first memory area; wherein, the first half of the area unit of the first memory area is used to store the method pointer, and the second half of the area unit of the first memory area is used to store the corresponding method pointer. Instruction offset value, the total number of area units in the first memory area is 2N;
- a first address obtaining module 403, configured to obtain the address of the first memory area
- the second memory application module 404 is configured to apply for a second memory area, and store the address of the first memory area into the first area unit in the second memory area; wherein, the total number of area units in the second memory area is N+1;
- the second address obtaining module 405 is configured to obtain the address of the second memory area
- the third memory application module 406 is configured to apply for a third memory area, obtain a target storage area in the third memory area, and store the address of the second memory area in the target storage area;
- the stack frame information acquisition module 407 is configured to execute the code segment corresponding to the stack frame information acquisition function module getStackTrace based on the address of the second memory area stored in the target storage area, and acquire information of each stack frame in the call stack to be processed.
- the first memory application module 402 is specifically configured to:
- the second memory application module 404 is specifically configured to:
- the third memory application module 406 is specifically used for:
- the order of appearance of the method pointer or the instruction offset value in the call stack to be processed is the same as the order of appearance in the first memory area.
- the stack frame information acquisition module 407 includes:
- the storage address return unit is used for, based on the address of the second memory area stored in the target storage area, executes the code segment corresponding to the stack frame information acquisition function module getStackTrace, and obtains the storage address of the information of each stack frame in the call stack to be processed;
- the stack frame information obtaining unit is configured to obtain the information of each stack frame based on the storage address.
- the storage address points to the stack frame information array, and each element in the stack frame information array corresponds to information of different stack frames.
- the information of each stack frame includes at least one of the following: the method name of the stack frame, the class name of the stack frame method, the source code file name corresponding to the stack frame, and the source code line number corresponding to the stack frame.
- the apparatus 400 for acquiring the stack frame information in the call stack provided by the embodiment of the present disclosure further includes:
- the stack frame information sending module is used for sending the information of each stack frame to the server; wherein, the server is used for analyzing the abnormality in the running process of the program based on the information of each stack frame.
- the call stack acquisition module 401 includes:
- the call stack acquisition unit is used to acquire multiple call stacks with exceptions during the running of the program
- the repeated call stack determination unit is used to determine the repeated call stacks in multiple call stacks by comparing the method pointers and instruction offset values in each call stack;
- the call stack deduplication unit is used to perform deduplication processing on multiple call stacks based on the repeated call stacks to obtain the to-be-processed call stacks.
- the apparatus for obtaining the stack frame information in the call stack provided by the embodiments of the present disclosure can execute any method for obtaining the stack frame information in the call stack provided by the embodiments of the present disclosure, and has function modules and beneficial effects corresponding to the execution methods. .
- any method for obtaining the stack frame information in the call stack provided by the embodiments of the present disclosure and has function modules and beneficial effects corresponding to the execution methods. .
- FIG. 5 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure, which is used to exemplarily illustrate an electronic device implementing the method for acquiring stack frame information in a call stack provided by the embodiment of the present disclosure.
- the electronic devices in the embodiments of the present disclosure may include, but are not limited to, such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablets), PMPs (portable multimedia players), vehicle-mounted terminals (eg, Mobile terminals such as car navigation terminals), etc., and stationary terminals such as digital TVs, desktop computers, smart home devices, wearable electronic devices, servers, and the like.
- the electronic device shown in FIG. 5 is only an example, and should not impose any limitation on the functions and occupancy scope of the embodiments of the present disclosure.
- electronic device 500 includes one or more processors 501 and memory 502 .
- Processor 501 may be a central processing unit (CPU) or other form of processing unit having data processing capabilities and/or instruction execution capabilities, and may control other components in electronic device 500 to perform desired functions.
- CPU central processing unit
- Memory 502 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory.
- Volatile memory may include, for example, random access memory (RAM) and/or cache memory, among others.
- Non-volatile memory may include, for example, read only memory (ROM), hard disk, flash memory, and the like.
- One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 501 may execute the program instructions to implement the method for acquiring stack frame information in the call stack provided by the embodiments of the present disclosure, and may also achieve other expectations function.
- Various contents such as input signals, signal components, noise components, etc. may also be stored in the computer-readable storage medium.
- the method for obtaining stack frame information in a call stack may include: obtaining a call stack to be processed that has an exception in the running process of a program; wherein, each area unit of the call stack to be processed includes a method pointer And the instruction offset value corresponding to the method pointer, the total number of area units of the call stack to be processed is N; apply for the first memory area; wherein, the first half of the area units of the first memory area are used to store the method pointer, and the first memory area is used to store the method pointer.
- the second half of the area unit is used to store the instruction offset value corresponding to the method pointer, and the total number of area units in the first memory area is 2N; obtain the address of the first memory area; apply for the second memory area, and place the first memory area.
- the address of a memory area is stored in the first area unit in the second memory area; wherein, the total number of area units in the second memory area is N+1; obtain the address of the second memory area; apply for the third memory area, and obtain the target storage area in the third memory area, and store the address of the second memory area into the target storage area; based on the address of the second memory area stored in the target storage area, execute the stack frame information to obtain the code segment corresponding to the function module getStackTrace , to obtain the information of each stack frame in the call stack to be processed.
- the electronic device 500 may also perform other optional implementations provided by the method embodiments of the present disclosure.
- the electronic device 500 may also include an input device 503 and an output device 504 interconnected by a bus system and/or other form of connection mechanism (not shown).
- the input device 503 may also include, for example, a keyboard, a mouse, and the like.
- the output device 504 can output various information to the outside, including the determined distance information, direction information, and the like.
- the output device 504 may include, for example, displays, speakers, printers, and communication networks and their connected remote output devices, among others.
- the electronic device 500 may also include any other appropriate components according to the specific application.
- the embodiments of the present disclosure also provide a computer program product, which includes a computer program or computer program instructions, and the computer program or computer program instructions, when executed by a computing device, cause the computing device to implement what is provided by the embodiments of the present disclosure. Any method used to obtain the stack frame information in the call stack.
- the computer program product may write program code for performing operations of embodiments of the present disclosure in any combination of one or more programming languages, including object-oriented programming languages, such as Java, C++, etc., as well as conventional procedural programming language, such as "C" language or similar programming language.
- the program code may execute entirely on the user electronic device, partly on the user electronic device, as a stand-alone software package, partly on the user electronic device and partly on the remote electronic device, or entirely on the remote electronic device execute on.
- embodiments of the present disclosure may further provide a computer-readable storage medium on which computer program instructions are stored, and when executed by the computing device, the computer program instructions cause the computing device to implement any method for obtaining calls provided by the embodiments of the present disclosure.
- Method for stack frame information in the stack may be provided by the embodiments of the present disclosure.
- the method for obtaining stack frame information in a call stack may include: obtaining a call stack to be processed that has an exception in the running process of a program; wherein, each area unit of the call stack to be processed includes a method pointer And the instruction offset value corresponding to the method pointer, the total number of area units of the call stack to be processed is N; apply for the first memory area; wherein, the first half of the area units of the first memory area are used to store the method pointer, and the first memory area is used to store the method pointer.
- the second half of the area unit is used to store the instruction offset value corresponding to the method pointer, and the total number of area units in the first memory area is 2N; obtain the address of the first memory area; apply for the second memory area, and place the first memory area.
- the address of a memory area is stored in the first area unit in the second memory area; wherein, the total number of area units in the second memory area is N+1; obtain the address of the second memory area; apply for the third memory area, and obtain the target storage area in the third memory area, and store the address of the second memory area into the target storage area; based on the address of the second memory area stored in the target storage area, execute the stack frame information to obtain the code segment corresponding to the function module getStackTrace , to obtain the information of each stack frame in the call stack to be processed.
- the computing device can also cause the computing device to implement other optional implementations provided by the method embodiments of the present disclosure.
- a computer-readable storage medium can employ any combination of one or more readable media.
- the readable medium may be a readable signal medium or a readable storage medium.
- the readable storage medium may include, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses or devices, or a combination of any of the above. More specific examples (non-exhaustive list) of readable storage media include: electrical connections with one or more wires, portable disks, hard disks, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Health & Medical Sciences (AREA)
- Biomedical Technology (AREA)
- Executing Machine-Instructions (AREA)
- Debugging And Monitoring (AREA)
Abstract
Description
Claims (10)
- 一种用于获取调用栈中栈帧信息的方法,其特征在于,包括:获取程序运行过程中存在异常的待处理调用栈;其中,所述待处理调用栈的每个区域单元中包括方法指针以及与所述方法指针对应的指令偏移值,所述待处理调用栈的区域单元总个数为N;申请第一内存区域;其中,所述第一内存区域的前半部分区域单元用于存储所述方法指针,所述第一内存区域的后半部分区域单元用于存储与所述方法指针对应的指令偏移值,所述第一内存区域的区域单元总个数为2N;获取所述第一内存区域的地址;申请第二内存区域,并将所述第一内存区域的地址存入所述第二内存区域中的第一个区域单元;其中,所述第二内存区域的区域单元总个数为N+1;获取所述第二内存区域的地址;申请第三内存区域,并获取所述第三内存区域中的目标存储区域,将所述第二内存区域的地址存入所述目标存储区域;基于所述目标存储区域存储的所述第二内存区域的地址,执行栈帧信息获取功能模块getStackTrace对应的代码段,获取所述待处理调用栈中各栈帧的信息。
- 根据权利要求1所述的方法,其特征在于:申请第一内存区域,包括:为属于整型或者长整型的第一数组申请所述第一内存区域;其中,所述第一数组的元素分别存储在所述第一内存区域的区域单元中;申请第二内存区域,包括:为对象基类Object下的第二数组申请所述第二内存区域;其中,所述第二数组的元素分别存储在所述第二内存区域的区域单元中;申请第三内存区域,包括:为异常父类Throwable下的目标对象申请所述第三内存区域。
- 根据权利要求1所述的方法,其特征在于,所述方法指针或者所述指令偏移值在所述待处理调用栈中的出现顺序与在所述第一内存区域中的出现顺序相同。
- 根据权利要求1所述的方法,其特征在于,基于所述目标存储区域存储的所述第二内存区域的地址,执行栈帧信息获取功能模块getStackTrace对应的代码段,获取所述待处理调用栈中各栈帧的信息,包括:基于所述目标存储区域存储的所述第二内存区域的地址,执行所述栈帧信息获取功能模块getStackTrace对应的代码段,获取所述待处理调用栈中各栈帧的信息的存储地址;基于所述存储地址,获取所述各栈帧的信息。
- 根据权利要求1所述的方法,其特征在于,所述各栈帧的信息包括以下至少之一:栈帧的方法名、栈帧方法所在类名、栈帧对应的源码文件名和栈帧对应的源码行号。
- 根据权利要求1所述的方法,其特征在于,还包括:将所述各栈帧的信息发送至服务端;其中,所述服务端用于基于所述各栈帧的信息分析程序运行过程中的异常。
- 根据权利要求1所述的方法,其特征在于,获取程序运行过程中存在异常的调用栈,包括:获取程序运行过程中存在异常的多个调用栈;通过对比各个调用栈中的所述方法指针和所述指令偏移值,确定所述多个调用栈中的重复调用栈;基于所述重复调用栈对所述多个调用栈进行去重处理,得到所述待处理调用栈。
- 一种用于获取调用栈中栈帧信息的装置,其特征在于,包括:调用栈获取模块,用于获取程序运行过程中存在异常的待处理调用栈;其中,所述待处理调用栈的每个区域单元中包括方法指针以及与所述方法指针对应的指令偏移值,所述待处理调用栈的区域单元总个数为N;第一内存申请模块,用于申请第一内存区域;其中,所述第一内存区域的前半部分区域单元用于存储所述方法指针,所述第一内存区域的后半部分区域单元用于存储与所述方法指针对应的指令偏移值,所述第一内存区域的区域单元总个数为2N;第一地址获取模块,用于获取所述第一内存区域的地址;第二内存申请模块,用于申请第二内存区域,并将所述第一内存区域的地址存入所述第二内存区域中的第一个区域单元;其中,所述第二内存区域的区域单元总个数为N+1;第二地址获取模块,用于获取所述第二内存区域的地址;第三内存申请模块,用于申请第三内存区域,并获取所述第三内存区域中的目标存储区域,将所述第二内存区域的地址存入所述目标存储区域;栈帧信息获取模块,用于基于所述目标存储区域存储的所述第二内存区域的地址,执行栈帧信息获取功能模块getStackTrace对应的代码段,获取所述待处理调用栈中各栈帧的信息。
- 一种电子设备,其特征在于,包括存储器和处理器,其中,所述存储器中存储有计算机程序,当所述计算机程序被所述处理器执行时,使得所述电子设备实现权利要求1-7中任一项所述的用于获取调用栈中栈帧信息的方法。
- 一种计算机可读存储介质,其特征在于,所述存储介质中存储有计算机程序,当所述计算机程序被计算设备执行时,使得所述计算设备实现权利要求1-7中任一项所述的 用于获取调用栈中栈帧信息的方法。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US18/277,005 US20240126627A1 (en) | 2021-03-22 | 2022-02-28 | Method and apparatus for obtaining information of stack frame in call stack, device, and medium |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110303887.1 | 2021-03-22 | ||
CN202110303887.1A CN112905381B (zh) | 2021-03-22 | 2021-03-22 | 用于获取调用栈中栈帧信息的方法、装置、设备和介质 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022199331A1 true WO2022199331A1 (zh) | 2022-09-29 |
Family
ID=76105898
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/078365 WO2022199331A1 (zh) | 2021-03-22 | 2022-02-28 | 用于获取调用栈中栈帧信息的方法、装置、设备和介质 |
Country Status (3)
Country | Link |
---|---|
US (1) | US20240126627A1 (zh) |
CN (1) | CN112905381B (zh) |
WO (1) | WO2022199331A1 (zh) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112905381B (zh) * | 2021-03-22 | 2022-12-06 | 北京字节跳动网络技术有限公司 | 用于获取调用栈中栈帧信息的方法、装置、设备和介质 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103106132A (zh) * | 2013-03-05 | 2013-05-15 | 中标软件有限公司 | Linux系统崩溃时内核函数调用栈分析调试方法 |
CN111813465A (zh) * | 2020-06-19 | 2020-10-23 | 北京字节跳动网络技术有限公司 | 一种信息获取方法、装置、介质和设备 |
US20200371945A1 (en) * | 2019-05-22 | 2020-11-26 | Vdoo Connected Trust Ltd. | Dynamic Identification of Stack Frames |
CN112084024A (zh) * | 2020-08-31 | 2020-12-15 | 北京字节跳动网络技术有限公司 | 一种内存监控方法、装置、介质和电子设备 |
CN112905381A (zh) * | 2021-03-22 | 2021-06-04 | 北京字节跳动网络技术有限公司 | 用于获取调用栈中栈帧信息的方法、装置、设备和介质 |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103019707B (zh) * | 2012-11-30 | 2016-01-27 | 华为技术有限公司 | 调用栈的解析处理方法及装置 |
CN110764941B (zh) * | 2019-09-05 | 2023-04-18 | 北京字节跳动网络技术有限公司 | 获取调用栈栈帧指令偏移的方法、装置、介质和设备 |
US11442739B2 (en) * | 2019-09-16 | 2022-09-13 | International Business Machines Carporation | Exception handling |
-
2021
- 2021-03-22 CN CN202110303887.1A patent/CN112905381B/zh active Active
-
2022
- 2022-02-28 US US18/277,005 patent/US20240126627A1/en active Pending
- 2022-02-28 WO PCT/CN2022/078365 patent/WO2022199331A1/zh active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103106132A (zh) * | 2013-03-05 | 2013-05-15 | 中标软件有限公司 | Linux系统崩溃时内核函数调用栈分析调试方法 |
US20200371945A1 (en) * | 2019-05-22 | 2020-11-26 | Vdoo Connected Trust Ltd. | Dynamic Identification of Stack Frames |
CN111813465A (zh) * | 2020-06-19 | 2020-10-23 | 北京字节跳动网络技术有限公司 | 一种信息获取方法、装置、介质和设备 |
CN112084024A (zh) * | 2020-08-31 | 2020-12-15 | 北京字节跳动网络技术有限公司 | 一种内存监控方法、装置、介质和电子设备 |
CN112905381A (zh) * | 2021-03-22 | 2021-06-04 | 北京字节跳动网络技术有限公司 | 用于获取调用栈中栈帧信息的方法、装置、设备和介质 |
Non-Patent Citations (2)
Title |
---|
LIANG YU, FU JIANMING;PENG GUOJUN;PENG BICHEN: "S-Tracker: Shellcode Detection Method Based on Stack Irregularity", HUAZHONG KEJI DAXUE XUEBAO (ZIRAN KEXUE BAN)/JOURNAL OF HUAZHONG UNIVERSITY OF SCIENCE AND TECHNOLOGY (NATURAL SCIENCE EDITION), HUAZHONG KEJI DAXUE, CN, vol. 42, no. 11, 30 November 2014 (2014-11-30), CN , pages 39 - 46, XP055969960, ISSN: 1671-4512, DOI: 10.13245/j.hust.141108 * |
WEI HUANG ; ZHEN HUANG ; DHAVAL MIYANI ; DAVID LIE: "LMP:Light-Weighted Memory Protection with Hardware Assistance", COMPUTER SECURITY APPLICATIONS, ACM, 2 PENN PLAZA, SUITE 701 NEW YORK NY 10121-0701 USA, 5 December 2016 (2016-12-05) - 8 December 2016 (2016-12-08), 2 Penn Plaza, Suite 701 New York NY 10121-0701 USA , pages 460 - 470, XP058306824, ISBN: 978-1-4503-4771-6, DOI: 10.1145/2991079.2991089 * |
Also Published As
Publication number | Publication date |
---|---|
US20240126627A1 (en) | 2024-04-18 |
CN112905381B (zh) | 2022-12-06 |
CN112905381A (zh) | 2021-06-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10496335B2 (en) | Method and apparatus for performing multi-object transformations on a storage device | |
US7761586B2 (en) | Accessing and manipulating data in a data flow graph | |
AU2014203518B2 (en) | Cloud-scale heterogeneous datacenter management infrastructure | |
US9183065B1 (en) | Providing access to an application programming interface through a named pipe | |
WO2023231345A1 (zh) | 对多个交易进行分组的方法和区块链节点 | |
WO2022199284A1 (zh) | 调用栈回溯方法、装置、设备和介质 | |
US10275175B2 (en) | System and method to provide file system functionality over a PCIe interface | |
US8910136B2 (en) | Generating code that calls functions based on types of memory | |
WO2022199283A1 (zh) | 用于确定调用栈栈帧的对象的方法、装置、设备和介质 | |
US20200117722A1 (en) | Efficient file storage and retrieval system, method and apparatus | |
JP5062909B2 (ja) | 1つのディレクトリから別のディレクトリへのファイルのコピー | |
US20220365709A1 (en) | Computational storage for logical volumes that span physical devices | |
WO2022199331A1 (zh) | 用于获取调用栈中栈帧信息的方法、装置、设备和介质 | |
WO2018113030A1 (en) | Technology to implement bifurcated non-volatile memory express driver | |
US20050228920A1 (en) | Interrupt system using event data structures | |
US9792042B2 (en) | Systems and methods for set membership matching | |
CN110781159A (zh) | Ceph目录文件信息读取方法、装置、服务器及存储介质 | |
US11681550B2 (en) | Command management using allocated command identifier pools | |
US11347501B1 (en) | Shape-based code comparisons | |
US11200203B1 (en) | Accessing files stored in a firmware volume from a pre-boot application | |
US8935710B1 (en) | Unique event identification | |
KR20160082229A (ko) | 프로세싱을 수행하는 컴퓨팅 시스템 및 그것의 동작 방법 | |
US8892807B2 (en) | Emulating a skip read command | |
CN108874387A (zh) | 一种数据序列化方法及其相关设备 | |
US20210248106A1 (en) | Systems and methods for updating select files in an image backup |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 22773993 Country of ref document: EP Kind code of ref document: A1 |
|
WWE | Wipo information: entry into national phase |
Ref document number: 18277005 Country of ref document: US |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 17.01.2024) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 22773993 Country of ref document: EP Kind code of ref document: A1 |