Virtual machine stack backtracking method and device and storage medium

By judging and obtaining the stack top pointer and return address of the native method, or matching the instruction content to calculate the memory address, it solves the problem of large performance loss of the Java virtual machine in the Native method stack backtrace, achieves fast and accurate stack backtrace, and improves Performance and instrumentation data representativeness of Java applications.

CN118585370APending Publication Date: 2024-09-03WUXI ADVANCED TECH RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410904591.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

The original algorithm of the Java virtual machine cannot accurately implement Native method stack traceback, especially when the stack top pointer in the stack frame generated by the basic C/C++ compiler does not have fixed offset storage characteristics, resulting in large performance losses and affecting the performance of Java applications. Representativeness of performance and performance testing data.

Method used

By determining whether the current method is a local method and obtaining the stack top pointer and return address of the parent method when the thread is paused, or by reading the high-order field of the instruction content to match the instruction type to calculate the memory address, stack backtracing is achieved and avoids reliance on fixed offsets. Shift storage and stack bottom pointer.

Benefits of technology

It realizes fast and accurate method stack backtracking on different processor platforms, reduces performance loss, and ensures the representativeness of performance testing data of Java testing tools.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118585370A
    Figure CN118585370A
Patent Text Reader

Abstract

The invention discloses a virtual machine stack backtracking method and device and a storage medium. The method comprises the steps that whether a current method is a local method or not is judged; if the current method is the local method, judging whether the current method is a method being executed when the thread is paused or not; if the current method is a method being executed when the thread is paused, directly obtaining a stack top pointer of a parent method of the current method and a return address of the parent method from a corresponding register through context information so as to perform stack backtracking; if the current method is not the method being executed when the thread is paused, obtaining a stack top pointer of a parent method of the current method and a return address of the current method through the obtained information; reading the instruction content of the corresponding address according to the obtained stack top pointer of the parent method and the return address of the current method, intercepting the high-order field of the instruction, and obtaining the stack top pointer and the return address of the parent stack method from the stack according to the intercepted instruction content so as to perform stack backtracking; according to the method, the local method stack backtracking function required by the Java detection tool can be correctly and quickly realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a virtual machine stack backtracing method, device and storage medium, belonging to the technical field of Java virtual machine just-in-time compilation. Background Art

[0002] A stack frame is a data structure used to store method call information in computer memory. The compiler correctly handles method calls and returns through the stack frame structure. When calling and returning methods, the computer uses the stack to maintain the control flow of execution. Java virtual machine performance monitoring tools need to collect and record the performance data of the Java virtual machine at runtime, including the native method stack and Java method stack called by JNI. In the process of obtaining the method call stack, the stack frame needs to be traversed in reverse. The traversal process requires that the stack top pointer and return address of the parent stack can be accurately located each time. The ABI (Application Binary Interface) of the basic C / C++ compiler of different architectures is different. One type stores the stack top pointer and return address of the method at a fixed offset of the stack frame, and the other type stores it at an unfixed offset. Currently, the Java virtual machine only implements stack backtracking of the native method stack when the stack top pointer and return address are fixed.

[0003] When the stack top pointer of the stack frame generated by the basic C / C++ compiler does not have the fixed offset storage feature, the original algorithm of the Java virtual machine cannot accurately implement stack backtracing for native methods. When stack backtracing relies on program counter values ​​and call frame information (CFI) records, it is necessary to scan the program counter value segment multiple times to locate the parent stack pointer, which results in a large performance loss. Stack backtracing for performance monitoring purposes needs to minimize the performance loss of the stack backtracing process on the application. The stack backtracing method that relies on call stack information has a large performance overhead, which will cause the performance of the Java application to degrade, and the performance detection data is not representative. Summary of the invention

[0004] The purpose of the present invention is to overcome the deficiencies in the prior art and to provide a virtual machine stack backtracing method, device and storage medium, which can correctly and quickly implement the method stack backtracing function required by a Java detection tool.

[0005] To achieve the above object, the present invention is implemented by adopting the following technical solutions: In a first aspect, the present invention provides a virtual machine stack backtracking method. In a Java virtual machine stack backtracking process, when it is necessary to obtain a stack top pointer of a current method, the following steps are performed: Determine whether the current method is a local method; If the current method is a local method, determine whether the current method is the method being executed when the thread is suspended; If the current method is the method being executed when the thread is suspended, the stack top pointer and the return address of the parent method of the current method are directly obtained from the corresponding register through the context information to perform stack backtracking; If the current method is not the method being executed when the thread is suspended, the stack top pointer of the parent method of the current method and the return address of the current method are obtained through the information that has been obtained; Read the instruction content of the corresponding address according to the obtained stack top pointer of the parent method and the return address of the current method, intercept the high-order field of the instruction, and determine whether the instruction content is one of the following: Instruction 1: Instruction to set the stack top pointer of the parent method; Instruction 2: Instruction to set the return address; Instruction 3: Instruction to identify the current method as the head method; If the matched instruction is instruction 1 or instruction 2, the memory address containing the return address of the parent method is calculated according to the offset in the instruction, and the return address of the parent method is read from the memory address. The stack is backtracked according to the obtained stack top pointer of the parent method and the return address of the parent method. If the matched instruction is instruction 3, it is determined that the current method is a head method and has no parent method, and the stack backtracking ends.

[0006] Furthermore, if the current method is not a native method, a traditional algorithm is used to perform stack backtracking.

[0007] Furthermore, the acquired information includes: the sub-method stack backtracking has acquired the stack top pointer of the current method stack and the program count value of the next instruction of the current method calling the sub-method instruction.

[0008] Furthermore, the instruction content is 32 bits long and occupies 4 bytes in the memory. Each time the method code area is traversed in reverse, the program counter value decreases by 4.

[0009] Furthermore, when calculating the memory address containing the return address of the parent method, add the offset value to the stack top pointer of the current method, calculate the memory address, read 8 bytes of data from the memory address, and the read 8 bytes of data are the 64-bit address value of the stack top pointer or return address of the parent method.

[0010] Furthermore, the stack backtracking method is applicable to a system based on a reduced instruction set processor, wherein the memory instruction format is 32 bits, wherein the upper 16 bits correspond to the instruction code and the source and destination registers, and the lower 16 bits correspond to the offset value.

[0011] In a second aspect, the present invention provides a virtual machine stack backtracking device, applicable to a Java virtual machine, comprising: A first judgment module is used to judge whether the current method is a local method; A second determination module is used to further determine whether the current method is the method being executed when the thread is suspended when the first determination module determines that the current method is a local method; If the current method is the method being executed when the thread is suspended, the stack top pointer and the return address of the parent method of the current method are directly obtained from the corresponding register through the context information to perform stack backtracking; If the current method is not the method being executed when the thread is suspended, the stack top pointer of the parent method of the current method and the return address of the current method are obtained through the information that has been obtained; The third judgment module is used to read the instruction content of the corresponding address according to the obtained stack top pointer of the parent method and the return address of the current method, intercept the high-order field of the instruction, and judge whether the instruction content is one of the following: Instruction 1: Instruction to set the stack top pointer of the parent method; Instruction 2: Instruction to set the return address; Instruction 3: Instruction to identify the current method as the head method; If the matched instruction is instruction 1 or instruction 2, the memory address containing the return address of the parent method is calculated according to the offset in the instruction, and the return address of the parent method is read from the memory address. The stack is backtracked according to the obtained stack top pointer of the parent method and the return address of the parent method. If the matched instruction is instruction 3, it is determined that the current method is a head method and has no parent method, and the stack backtracking ends.

[0012] In a third aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the aforementioned methods.

[0013] In a fourth aspect, the present invention provides a computer device, comprising: Memory, for storing computer programs / instructions; A processor is used to execute the computer program / instructions to implement the steps of any of the aforementioned methods.

[0014] In a fifth aspect, the present invention provides a computer program product, comprising a computer program / instruction, which implements the steps of any one of the aforementioned methods when executed by a processor.

[0015] Compared with the prior art, the present invention has the following beneficial effects: The present invention provides a virtual machine stack backtracking method, device and storage medium. For different processor platforms, only the judgment condition of the termination of the stack backtracking algorithm needs to be fine-tuned to be applicable. Different from the traditional stack backtracking method that needs to rely on a fixed offset to simultaneously locate the stack top pointer, stack bottom pointer and return address, the method of the present invention locates the parent stack bottom pointer and return address by reverse matching instruction content, and can complete the stack backtracking of the entire method stack without relying on fixed offset storage and stack bottom pointer. The position of the parent stack top pointer and return address on the stack is located by reverse traversal without calling the stack backtracking method provided by the basic library. Although it is impossible to obtain more comprehensive register information, it can correctly and quickly realize the method stack backtracking function required by the Java detection tool. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a flow chart of a virtual machine stack backtracing method provided by an embodiment of the present invention; Figure 2 It is a schematic diagram of a memory instruction format of a reduced instruction set processor provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0017] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.

[0018] Embodiment 1: This embodiment introduces a virtual machine stack backtracking method. In the Java virtual machine stack backtracking process, when it is necessary to obtain the stack top pointer of the current method, the following steps are performed: Determine whether the current method is a local method; If the current method is a local method, determine whether the current method is the method being executed when the thread is suspended; If the current method is the method being executed when the thread is suspended, the stack top pointer and the return address of the parent method of the current method are directly obtained from the corresponding register through the context information to perform stack backtracking; If the current method is not the method being executed when the thread is suspended, the stack top pointer of the parent method of the current method and the return address of the current method are obtained through the information that has been obtained; Read the instruction content of the corresponding address according to the obtained stack top pointer of the parent method and the return address of the current method, intercept the high-order field of the instruction, and determine whether the instruction content is one of the following: Instruction 1: Instruction to set the stack top pointer of the parent method; Instruction 2: Instruction to set the return address; Instruction 3: Instruction to identify the current method as the head method; If the matched instruction is instruction 1 or instruction 2, the memory address containing the return address of the parent method is calculated according to the offset in the instruction, and the return address of the parent method is read from the memory address. The stack is backtracked according to the obtained stack top pointer of the parent method and the return address of the parent method. If the matched instruction is instruction 3, it is determined that the current method is a head method and has no parent method, and the stack backtracking ends.

[0019] Among them, the current method refers to the method being executed by the current application thread, the parent method refers to the method that calls the current method, and the head method refers to the first method that the current application thread starts to execute. These methods can be logical operations, conditional selections, loop calls, and other methods executed by the current application thread.

[0020] The application process of the virtual machine stack backtracing method provided in this embodiment specifically involves the following steps: For the convenience of description, the parent method of the current method is called method A, and the parent method of method A is called method B. The stack backtracking process is an iterative process. Here, the algorithm process is simplified to describe only the process of the algorithm processing the first three methods and the last method, omitting the intermediate iterative process.

[0021] When the Java virtual machine performance monitoring tool completes the collection of the method call stack, the stack backtracking thread of the Java virtual machine performance detection tool first modifies the semaphore. After the application thread reads the semaphore, it actively triggers the exception defined by the Java virtual machine and enters the waiting pause state; after the stack backtracking thread determines that the user thread has been suspended, it obtains the context information of the application thread and records the method name of the current method; according to the return address register in the context, it obtains the execution position of the parent method A of the current method, and based on this program count position, it reversely traverses the code cache to find the instruction operation of storing the stack top pointer register of the B method stack and the return address register of the A method into the memory stack; according to the instruction, it obtains the stack top pointer and program count position of the B method on the stack offset by a certain distance from the stack top pointer of the A method. The entire method stack can be traversed by continuous iteration until there is no operation to save the stack top pointer in the method instruction, and then the stack backtracking is concluded to be over.

[0022] Figure 1 This is a flowchart of the stack backtracking process. The steps of the algorithm are as follows: Step 1) When the Java virtual machine stack backtracking thread obtains the stack top pointer sp of the current method, it determines whether the current method is a native method. If it is not a native method, it is a common Java method. The stack frame of the Java method has the characteristic of storing the return address of the top and bottom of the stack at a fixed offset. Only the traditional algorithm needs to be used without additional processing. Among them, the traditional algorithm is a stack backtracking algorithm based on the stack bottom pointer and fixed offset. The algorithm steps are: find the parent stack bottom pointer on the stack according to the current stack bottom pointer plus the fixed offset.

[0023] Step 2) If it is a native method, determine whether the stack top pointer and return address of the parent method have been obtained from the context, that is, determine whether the current method is the method being executed when the thread is suspended. If the judgment is true, the stack top pointer and return address of the parent stack are directly obtained from the corresponding registers through the context.

[0024] Step 3) If the current method is not the method being executed, the information obtained at this time includes: the child method stack backtracking has obtained the stack top pointer of the current method stack and the program counter value of the next instruction of the current method calling the child method instruction. Next, based on these two pieces of information, the parent method stack top pointer and the return address of the current method, that is, the program counter value of the next instruction of the parent method calling the current method instruction, are obtained.

[0025] Step 4) Read the 4-byte content of the corresponding address according to the current program counter value, that is, the instruction content. The reduced instruction set architecture has the characteristic of fixed instruction length. The processor instruction length involved in the present invention is 32 bits, which occupies 4 bytes in the memory. Each time the method code area is traversed in reverse, it is only necessary to subtract 4 from the program counter value.

[0026] Step 5) Intercept the high-order field (high 16 bits) of the instruction and determine whether the instruction content is one of the following instructions: Instruction 1': STORE STACKP , num1(SP) Instruction 2': STORE RETURNA, num2(SP) Instruction 3': LOADH GLOBALP , num3(TOA) Note: ① Instruction 1': Store the value in the STACKP register into the current stack top pointer SP+num1.

[0027] ② Instruction 2': Store the value in the RETURNA register into the current stack top pointer SP+num2.

[0028] ③ Instruction 3': Store the value of TOA+num3 into the GLOBALP register.

[0029] The stack backtracking algorithm of the present invention is based on a reduced instruction set processor, and the memory instruction format is as follows Figure 2 As shown, it can be seen that the high 16 bits of the 32-bit instruction correspond to the instruction code and the source and destination registers, and the low 16 bits correspond to the offset num. The present invention is based on the logic design of the basic C / C++ compiler in processing method calls. It is known that the Native method is a C method, and the method is compiled by the basic C / C++ compiler. The processing process of the basic C / C++ compiler when involving method calls is as follows: in the parent method, the SP register and the STACKP register both point to the top of the stack of the parent method. When a method call is required, the destination address of the called method is first fixedly stored in the TOA register; then the program counter points to the destination address of the called method and starts to execute the called method; at this time, what is retained in the TOA register is actually the address of the first instruction of the called method; because the experimental platform does not support the read and write operations of the program counter register, it is necessary to calculate the relocation table pointer of the called method in advance according to the value of the TOA register and store it in the GLOBALP register (corresponding to instruction 3'); then the SP register is subtracted from the stack frame size required by the called method to point to the top of the stack of the called method; then the value of the STACKP register storing the parent method stack top pointer and the value of the RETURNA register storing the called method return address information are respectively stored on the called method stack (corresponding to instruction 1' and instruction 2').

[0030] Therefore, the actual semantics of matching the high 16-bit operations of the above three instructions are as follows: Instruction 1': Find the operation instruction to store the pointer to the top of the parent stack into the current method stack.

[0031] Instruction 2': Find the operation instruction that stores the return address into the current method stack.

[0032] Instruction 3': Find the operation instruction that calculates the relocation table pointer for the current method.

[0033] Step 5.1) If the matched instruction is instruction 1' or instruction 2', intercept the lower 16 bits of the instruction to obtain the offset value based on the current method stack top pointer. According to the memory address calculated by adding the offset value to the current method stack top pointer, read 8 bytes of data from this memory address. These 8 bytes store the 64-bit address value of the parent method stack top pointer or return address. After acquisition, if the parent method stack top pointer and the current method return address are already available, it means that the parent method stack is successfully located and the subsequent steps can be skipped directly. If there are still values ​​that have not been obtained, return to step 4 and continue to traverse upward.

[0034] Step 5.2) If the matched instruction is instruction 3', it means that instruction 1' and instruction 2' do not exist at the same time in the current method instruction, then this method must be a header method, it does not have a parent method, and the stack backtracking ends.

[0035] The operation of matching the corresponding instructions in this embodiment needs to be combined with the characteristics of the basic C / C++ compiler to ensure that it will appear and only appear once in a method, otherwise it will cause information errors and stack backtracking failure. Step 5) The reason for matching instructions 1' and 2' is that in order to correctly handle the calling and returning of methods, the basic C / C++ compiler needs to store the top pointer and return address of the parent stack in the current method stack after the stack frame is opened. The former can ensure that the top of the parent method is correctly found when the method returns, and the latter can ensure that the parent method continues to execute the parent method from the next statement after the call ends.

[0036] In the case of different instructions for different platforms, when executing a method that needs to rely on a stack frame to store data, a stack frame should be opened before the execution method, so it is natural to match the stack opening operation as the basis for the end of stack backtracking. The basis for terminating stack backtracking in the present invention is matching instruction 3', because the instruction for opening a stack frame on the platform to which the present invention is applied is the same as the instruction for canceling the stack frame. In the case of a method having a branch return, there will be a situation of mismatching instructions, causing the stack backtracking to end in advance. On the contrary, the operation of calculating the relocation table pointer of the called method according to the value in the TOA register is unique in the agreement and can be used as a mark to mark the start of the method operation.

[0037] This embodiment has taken into account the existence of leaf methods. Since leaf methods do not call other methods, they will only appear as the method being executed when paused during the stack backtracking process, and there is no need to traverse in reverse to directly obtain the parent stack information from the context. Non-pause methods must generate method calls, so the relocation table pointer must be calculated. This design can correctly end the stack backtracking.

[0038] In summary, this embodiment can be applied to different processor platforms by only fine-tuning the judgment conditions for the termination of the stack backtracking algorithm. Different from the traditional stack backtracking method that relies on a fixed offset to simultaneously locate the stack top pointer, stack bottom pointer, and return address, the method of the present invention locates the parent stack bottom pointer and return address by reverse matching the instruction content, and can complete the stack backtracking of the entire method stack without relying on fixed offset storage and stack bottom pointer. Although it is impossible to obtain more comprehensive register information by locating the parent stack top pointer and return address on the stack through reverse traversal without calling the stack backtracking method provided by the basic library, it can correctly and quickly implement the method stack backtracking function required by the Java detection tool.

[0039] Embodiment 2: This embodiment provides a virtual machine stack backtracking device, applicable to a Java virtual machine, including: A first judgment module is used to judge whether the current method is a local method; A second determination module is used to further determine whether the current method is the method being executed when the thread is suspended when the first determination module determines that the current method is a local method; If the current method is the method being executed when the thread is suspended, the stack top pointer and the return address of the parent method of the current method are directly obtained from the corresponding register through the context information to perform stack backtracking; If the current method is not the method being executed when the thread is suspended, the stack top pointer of the parent method of the current method and the return address of the current method are obtained through the information that has been obtained; The third judgment module is used to read the instruction content of the corresponding address according to the obtained stack top pointer of the parent method and the return address of the current method, intercept the high-order field of the instruction, and judge whether the instruction content is one of the following: Instruction 1: Instruction to set the stack top pointer of the parent method; Instruction 2: Instruction to set the return address; Instruction 3: Instruction to identify the current method as the head method; If the matched instruction is instruction 1 or instruction 2, the memory address containing the return address of the parent method is calculated according to the offset in the instruction, and the return address of the parent method is read from the memory address. The stack is backtracked according to the obtained stack top pointer of the parent method and the return address of the parent method. If the matched instruction is instruction 3, it is determined that the current method is a head method and has no parent method, and the stack backtracking ends.

[0040] The specific functional implementation of each of the above modules can be found in the relevant contents of the method in Example 1 and will not be elaborated here.

[0041] Embodiment 3, this embodiment provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the steps of any one of the methods described in Embodiment 1 are implemented.

[0042] Embodiment 4: This embodiment provides a computer device, including: Memory, for storing computer programs / instructions; A processor is used to execute the computer program / instructions to implement the steps of any method described in Example 1.

[0043] Embodiment 5: This embodiment provides a computer program product, including a computer program / instruction, which implements the steps of any method described in Embodiment 1 when executed by a processor.

[0044] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

[0045] It should be understood by those skilled in the art that the embodiments of the present disclosure may be provided as methods, systems or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0046] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram and the combination of processes and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0047] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0048] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0049] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present disclosure rather than to limit its protection scope. Although the present disclosure has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that after reading the present disclosure, those skilled in the art can still make various changes, modifications or equivalent substitutions to the specific implementation methods of the invention, but these changes, modifications or equivalent substitutions are all within the protection scope of the disclosed claims to be approved.

Claims

1. A virtual machine stack backtracking method, characterized in that: During the Java virtual machine native method stack backtracking process, when you need to obtain the stack top pointer of the current method, perform the following steps: Determine whether the current method is a local method; If the current method is a local method, determine whether the current method is the method being executed when the thread is suspended; If the current method is the method being executed when the thread is suspended, the stack top pointer and the return address of the parent method of the current method are directly obtained from the corresponding register through the context information to perform stack backtracking; If the current method is not the method being executed when the thread is suspended, the stack top pointer of the parent method of the current method and the return address of the current method are obtained through the information that has been obtained; Read the instruction content of the corresponding address according to the obtained stack top pointer of the parent method and the return address of the current method, intercept the high-order field of the instruction, and determine whether the instruction content is one of the following: Instruction 1: Instruction to set the stack top pointer of the parent method; Instruction 2: Instruction to set the return address; Instruction 3: Instruction to identify the current method as the head method; If the matched instruction is instruction 1 or instruction 2, the memory address containing the return address of the parent method is calculated according to the offset in the instruction, and the return address of the parent method is read from the memory address. The stack is backtracked according to the obtained stack top pointer of the parent method and the return address of the parent method. If the matched instruction is instruction 3, it is determined that the current method is a head method and has no parent method, and the stack backtracking ends.

2. The virtual machine stack backtracing method according to claim 1, characterized in that: If the current method is not a native method, the traditional algorithm is used to backtrace the stack.

3. The virtual machine stack backtracing method according to claim 1, characterized in that: The acquired information includes: the sub-method stack backtracking has acquired the stack top pointer of the current method stack and the program count value of the next instruction of the current method calling the sub-method instruction.

4. The virtual machine stack backtracing method according to claim 1, characterized in that: The instruction content is 32 bits long and occupies 4 bytes in the memory. Each time the method code area is traversed in reverse, the program count value decreases by 4.

5. The virtual machine stack backtracing method according to claim 1, characterized in that: When calculating the memory address containing the return address of the parent method, add the offset value to the stack top pointer of the current method, calculate the memory address, read 8 bytes of data from the memory address, and the 8 bytes of data read are the 64-bit address value of the stack top pointer or return address of the parent method.

6. The virtual machine stack backtracing method according to claim 1, characterized in that: The stack backtracking method is applicable to a system based on a reduced instruction set processor, wherein the memory instruction format is 32 bits, wherein the upper 16 bits correspond to the instruction code and the source and destination registers, and the lower 16 bits correspond to the offset value.

7. A virtual machine stack backtracking device, applicable to a Java virtual machine, characterized in that: include: A first judgment module is used to judge whether the current method is a local method; A second determination module is used to further determine whether the current method is the method being executed when the thread is suspended when the first determination module determines that the current method is a local method; If the current method is the method being executed when the thread is suspended, the stack top pointer and the return address of the parent method of the current method are directly obtained from the corresponding register through the context information to perform stack backtracking; If the current method is not the method being executed when the thread is suspended, the stack top pointer of the parent method of the current method and the return address of the current method are obtained through the information that has been obtained; The third judgment module is used to read the instruction content of the corresponding address according to the obtained stack top pointer of the parent method and the return address of the current method, intercept the high-order field of the instruction, and judge whether the instruction content is one of the following: Instruction 1: Instruction to set the stack top pointer of the parent method; Instruction 2: Instruction to set the return address; Instruction 3: Instruction to identify the current method as the head method; If the matched instruction is instruction 1 or instruction 2, the memory address containing the return address of the parent method is calculated according to the offset in the instruction, and the return address of the parent method is read from the memory address. The stack is backtracked according to the obtained stack top pointer of the parent method and the return address of the parent method. If the matched instruction is instruction 3, it is determined that the current method is a head method and has no parent method, and the stack backtracking ends.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 6 are implemented.

9. A computer device, characterized in that: include: Memory, for storing computer programs / instructions; A processor, configured to execute the computer program / instructions to implement the steps of the method according to any one of claims 1 to 6.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.