Variable-length instruction set system stack backtracing implementation method and device

By dynamically detecting instruction length in a variable-length instruction set system and using return registers to determine stack frame boundaries, the problem of relying on compiler options and memory overhead in existing technologies is solved, achieving efficient and accurate stack backtracking.

CN114756284BActive Publication Date: 2024-11-15SHENZHEN XINZHILIAN TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202210420252.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-21
Publication Date
2024-11-15
Estimated Expiration
2042-04-21

AI Technical Summary

Technical Problem

Existing stack backtracking methods in variable-length instruction set systems rely on compilation options or introduce memory overhead, resulting in limited use cases and low backtracking accuracy.

Method used

By dynamically detecting instruction length, stack frame parameters and valid instruction lengths are automatically determined. Stack frame boundaries are determined by pushing the instruction into the stack using the return register. This approach is suitable for variable instruction set systems and avoids compiler options and memory overhead.

Benefits of technology

It improves the efficiency and accuracy of stack backtracking, is applicable to variable-length instruction set systems, and solves the problem of high limitations in the use of existing technologies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114756284B_ABST
    Figure CN114756284B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for implementing stack backtracking of a variable-length instruction set system, the method comprising: determining the program running address of the current function stack frame, determining the first legal instruction length, offsetting the first legal instruction length from the reference address to the low address direction, obtaining the second address and the corresponding first parsing instruction, and after judging that the instruction is a push instruction and has triggered the return register to be pushed, determining the second address as the upper boundary of the current function; determining the second legal instruction length, offsetting the second legal instruction length from the second address to the high address direction, obtaining the third address and the corresponding second parsing instruction, after judging that the instruction is a push instruction and the third address is the jump address of the current function, determining the next-level function as the new current function, and re-executing the above process. It can be seen that the implementation of the present invention provides a stack backtracking scheme that can dynamically detect the instruction length, parse instructions and be applied to a variable-length instruction set system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software debugging, and in particular to a method and device for realizing stack backtracing of a variable-length instruction set system. Background Art

[0002] When developing software, developers need to obtain stack backtrace information of some functions and error sites when errors occur. With the stack backtrace information, they can quickly locate and debug software problems.

[0003] There are currently three main solutions for stack backtracing in the industry: 1) Use specific compilation options to construct a regular stack frame. The software can quickly and easily obtain the stack frame starting address, stack frame size and PC register value of each function through the regular stack frame, so that the stack backtracing calculation can be completed quickly; 2) Store the pop and push information of each function in advance. During the compilation stage, calculate the number of pops and pushes of each function and its function address and save them in a special program segment table. When performing stack backtracing, these special program segment tables are searched to obtain their pop and push numbers, so as to calculate the value of the stack top address register SP and the value of the return register LR, so as to quickly complete the stack backtracing calculation; 3) Calculate the stack frame size through instruction parsing to extract the backtracing information, which means parsing the type of instruction, calculating the size of the current stack frame and the stack offset that saves the value of the return register LR, and then extracting the value of the stack top address register SP of the previous level function and the jump address.

[0004] However, the three existing solutions all have limitations. The first solution relies on specific compilation options and requires that the stack frame register FP cannot be optimized, which limits its usage scenarios. The second solution also relies on specific compilation options and introduces some memory resource overhead, which also limits its usage scenarios. The third solution currently only supports fixed-length instruction set systems. In variable-length instruction set systems, it will extract wrong instructions, resulting in backtracking errors. It is therefore particularly important to provide a stack backtracking method that does not rely on additional compilation options and does not introduce additional memory overhead. Summary of the invention

[0005] The technical problem to be solved by the present invention is to provide a method and device for implementing stack backtracing of a variable-length instruction set system, which can dynamically detect the instruction length in the stack backtracing process, does not rely on additional compilation options and does not introduce additional memory overhead. The usage scenarios are less restrictive, and the backtracing efficiency and backtracing accuracy of the stack backtracing are improved.

[0006] In order to solve the above technical problems, the first aspect of the present invention discloses a method for implementing stack backtracing of a variable-length instruction set system, the method comprising:

[0007] Determine a stack frame parameter corresponding to a target stack frame of the current function, wherein the stack frame parameter corresponding to the target stack frame includes a first address corresponding to the target stack frame, wherein the first address is a program running address corresponding to the target stack frame, and the target stack frame is a first-level stack frame or a non-first-level stack frame;

[0008] According to a preset first instruction length detection algorithm, a first legal instruction length is determined, and the first legal instruction length is shifted toward a lower address direction based on the determined reference address to obtain a second address; the initially determined reference address is the first address;

[0009] Reading the first parsed instruction at the second address, and determining whether the first parsed instruction is a push instruction, and when determining that the first parsed instruction is the push instruction, determining whether the first parsed instruction has triggered the return register to complete the push, and when determining that the first parsed instruction has triggered the return register to complete the push, determining the second address as the upper boundary of the current function corresponding to the target stack frame;

[0010] Determine the second legal instruction length according to a preset second instruction length detection algorithm, and shift the second legal instruction length toward a higher address based on the second address to obtain a third address;

[0011] The second parsing instruction at the third address is read, and it is determined whether the second parsing instruction is the push instruction. When it is determined that the second parsing instruction is the push instruction, it is determined whether the third address is equal to the jump address corresponding to the current function, and the jump address corresponding to the current function stores a jump instruction for jumping from the current function to a post-calling function, and the post-calling function is a function whose function calling sequence is after the function calling sequence of the current function; when it is determined that the third address is equal to the jump address, the next-level function of the current function is determined as the new current function, and the operation of determining the stack frame parameters corresponding to the target stack frame of the current function is triggered.

[0012] As an optional implementation, in the first aspect of the present invention, the stack frame parameter further includes the value of the stack top register of the target stack frame;

[0013] Wherein, when the target stack frame is the non-first-level stack frame, the stack frame parameters corresponding to the target stack frame are determined in the following manner:

[0014] Calculate the value of the top register of the target stack frame of the current function according to the total push length corresponding to the previous level function of the current function and the value of the top register corresponding to the previous level function of the current function; wherein the total push length corresponding to the previous level function of the current function is determined according to the push length of each push instruction corresponding to the previous level function of the current function; wherein the previous level function of the current function is the function that has been most recently backtraced before the current function;

[0015] Based on the stack offset corresponding to the return register when running the previous level function of the current function, the value of the top of the stack register corresponding to the previous level function of the current function, and the total push length corresponding to the previous level function of the current function, the value of the return register when running the previous level function of the current function is determined, and based on the value of the return register when running the previous level function of the current function and the predetermined jump instruction length, the first address corresponding to the target stack frame of the current function is calculated.

[0016] As an optional embodiment, in the first aspect of the present invention, the method further comprises:

[0017] When it is determined that the first parsed instruction is not the push instruction, the second address is determined as a new reference address, and the step of determining the first legal instruction length according to the preset instruction length detection algorithm is re-executed, and the step of shifting the first legal instruction length in the direction of the lower address based on the determined reference address to obtain the second address is performed, and the step of reading the first parsed instruction at the second address and determining whether the first parsed instruction is a push instruction is performed;

[0018] And, the method further comprises:

[0019] When it is determined that the first parsed instruction is the push instruction, and it is determined that the first parsed instruction does not trigger the return register to complete the push, the second address is determined as a new reference address, and the step of determining the first legal instruction length according to the preset instruction length detection algorithm is re-executed, and the step of offsetting the first legal instruction length in the low address direction based on the determined reference address to obtain the step corresponding to the second address, and executing the step of reading the first parsed instruction at the second address and determining whether the first parsed instruction is a push instruction.

[0020] As an optional implementation manner, in the first aspect of the present invention, the determining whether the first parsed instruction is a push instruction includes:

[0021] Analyze the first parsing instruction to obtain an analysis result corresponding to the first parsing instruction, and determine whether the analysis result includes a predetermined feature code;

[0022] When it is determined that the analysis result includes the feature code, determining that the first parsing instruction is a push instruction;

[0023] When it is determined that the analysis result does not include the feature code, determining that the first parsed instruction is not a push instruction;

[0024] Furthermore, after determining that the third address is equal to the jump address, and before determining the next level function of the current function as the new current function, the method further includes:

[0025] Determine whether the jump address corresponding to the next level function of the current function is a preset task exit address; when it is determined that the jump address corresponding to the next level function of the current function is not the preset task exit address, determine that the jump address corresponding to the next level function of the current function stores a jump instruction for jumping from the next level function to the post-call function corresponding to the next level function of the current function, and trigger the execution of the operation of determining the next level function of the current function as the new current function;

[0026] When it is determined that the jump address corresponding to the next level function is the preset task exit address, the stack backtracking interface is exited.

[0027] As an optional implementation, in the first aspect of the present invention, when it is determined that the first parsing instruction has triggered the completion of pushing the return register onto the stack, after determining the second address as the upper boundary of the current function corresponding to the target stack frame, the method further includes:

[0028] Determine, according to the first parsing instruction, an instruction list corresponding to the first parsing instruction;

[0029] Analyze the instruction list to obtain a first quantity corresponding to a first setting parameter and a second quantity corresponding to a second setting parameter in the instruction list, wherein the first setting parameter is a parameter in a preset bit state among all bits included in the instruction list, and the second setting parameter is a parameter in a preset bit position interval and in the preset bit state among all bits included in the instruction list;

[0030] Determine a stack length corresponding to the first parsed instruction according to the first number and a preset register width;

[0031] Determine a stack offset corresponding to the return register according to the second number and the preset register width;

[0032] The value of the return register is determined according to the stack length, the stack offset and the determined value of the top register of the current function. The value of the return register is used to calculate the value of the program running address corresponding to the previous level function stack frame of the current function. The value of the program running address corresponding to the previous level function stack frame of the current function is used to determine the jump address corresponding to the next level function.

[0033] As an optional implementation, in the first aspect of the present invention, determining the first legal instruction length according to a preset first instruction length detection algorithm includes:

[0034] According to a preset first instruction length detection algorithm, the first preset length is shifted toward the lower address direction based on the determined reference address to obtain a first pending instruction;

[0035] Determine the running architecture type corresponding to the current stack backtrace, and determine the instruction set state according to the running architecture type, wherein the running architecture type corresponds to at least one instruction set state, and each instruction set state corresponds to at least one instruction length;

[0036] According to the instruction lengths respectively corresponding to each of the instruction set states, determining whether the instruction length of the first pending instruction is one of the instruction lengths corresponding to all the instruction set states;

[0037] When it is determined that the instruction length of the first pending instruction is not any instruction length corresponding to all the instruction set states, determining the second preset length as the first legal instruction length;

[0038] When it is determined that the instruction length of the first pending instruction is one of the instruction lengths corresponding to all the instruction set states, the first preset length is determined to be a first legal instruction length.

[0039] As an optional implementation, in the first aspect of the present invention, when the target stack frame is the first-level stack frame, determining the stack frame parameters corresponding to the target stack frame of the current function includes:

[0040] Calling a backtrace function according to a preset stack backtrace start instruction, and judging whether the currently running target function is an exception handling function according to the backtrace function, wherein the backtrace function is a function for starting a stack backtrace process;

[0041] When it is determined that the target function is the exception handling function, the determined exception stack is called to obtain the program running address corresponding to the exception information and the value corresponding to the stack top register as the stack frame parameter corresponding to the target stack frame of the current function;

[0042] When it is determined that the function to be processed is not the exception handling function, determining a designated task to be backtraced, and obtaining stack frame parameters corresponding to the designated task, determining the function where the stack frame parameters corresponding to the designated task are located as the current function, and determining the stack frame parameters corresponding to the designated task as stack frame parameters corresponding to the target stack frame of the current function; the designated task is a currently running task or a non-currently running task;

[0043] Wherein, obtaining the stack frame parameters corresponding to the specified task includes:

[0044] When the designated task is the currently running task, obtaining the program running address corresponding to the current CPU and the value corresponding to the stack top register according to the preset assembler as the stack frame parameters corresponding to the designated task;

[0045] When the designated task is the non-currently running task, the program running address and the value of the stack top register are extracted from the context information corresponding to the designated task as stack frame parameters corresponding to the designated task.

[0046] A second aspect of the present invention discloses a device for implementing stack backtracing of a variable-length instruction set system, the device comprising:

[0047] a determination module, configured to determine stack frame parameters corresponding to a target stack frame of a current function, wherein the stack frame parameters corresponding to the target stack frame include a first address corresponding to the target stack frame, wherein the first address is a program running address corresponding to the target stack frame, and the target stack frame is a first-level stack frame or a non-first-level stack frame;

[0048] An addressing module, configured to determine a first legal instruction length according to a preset first instruction length detection algorithm, and to shift the first legal instruction length in a lower address direction based on a determined reference address to obtain a second address; the initially determined reference address is the first address;

[0049] A push determination module, configured to read the first parsed instruction at the second address and determine whether the first parsed instruction is a push instruction;

[0050] A first judgment module, configured to judge whether the first parsing instruction has triggered a return register to complete the stacking when the stacking judgment module judges that the first parsing instruction is the stacking instruction;

[0051] The determination module is further configured to determine the second address as the upper boundary of the current function corresponding to the target stack frame when the first determination module determines that the first parsing instruction has triggered the return register to complete pushing;

[0052] The addressing module is further used to determine the second legal instruction length according to a preset second instruction length detection algorithm, and to shift the second legal instruction length toward a higher address based on the second address to obtain a third address;

[0053] The push determination module is further configured to read the second parsed instruction at the third address and determine whether the second parsed instruction is the push instruction;

[0054] The first judgment module is further used to judge whether the third address is equal to the jump address corresponding to the current function when the push judgment module judges that the second parsing instruction is the push instruction, the jump address corresponding to the current function stores a jump instruction for jumping from the current function to a post-call function, and the post-call function is a function whose function calling sequence is after the function calling sequence of the current function;

[0055] The determination module is also used to determine the next-level function of the current function as the new current function when the first judgment module determines that the third address is equal to the jump address, and trigger the execution of the operation of determining the stack frame parameters corresponding to the target stack frame of the current function.

[0056] As an optional implementation, in the second aspect of the present invention, the stack frame parameter further includes the value of the stack top register of the target stack frame;

[0057] Wherein, when the target stack frame is the non-first-level stack frame, the stack frame parameters corresponding to the target stack frame are determined in the following manner:

[0058] Calculate the value of the top register of the target stack frame of the current function according to the total push length corresponding to the previous level function of the current function and the value of the top register corresponding to the previous level function of the current function; wherein the total push length corresponding to the previous level function of the current function is determined according to the push length of each push instruction corresponding to the previous level function of the current function; wherein the previous level function of the current function is the function that has been most recently backtraced before the current function;

[0059] Based on the stack offset corresponding to the return register when running the previous level function of the current function, the value of the top of the stack register corresponding to the previous level function of the current function, and the total push length corresponding to the previous level function of the current function, the value of the return register when running the previous level function of the current function is determined, and based on the value of the return register when running the previous level function of the current function and the predetermined jump instruction length, the first address corresponding to the target stack frame of the current function is calculated.

[0060] As an optional implementation, in the second aspect of the present invention, the determination module is also used to determine the second address as a new reference address when the push judgment module determines that the first parsed instruction is not the push instruction, and trigger the addressing module to re-execute the operation of determining the first legal instruction length according to the preset instruction length detection algorithm, offsetting the first legal instruction length in the direction of a lower address based on the determined reference address to obtain the second address, and triggering the push judgment module to execute the operation of reading the first parsed instruction at the second address and determining whether the first parsed instruction is a push instruction;

[0061] The determination module is also used to determine the second address as the new reference address when the push judgment module determines that the first parsing instruction is the push instruction and the first judgment module determines that the first parsing instruction does not trigger the return register to complete the push, and trigger the addressing module to re-execute the detection algorithm according to the preset instruction length to determine the first legal instruction length, and to offset the first legal instruction length in the direction of the lower address based on the determined reference address to obtain the operation corresponding to the second address, and trigger the push judgment module to execute the operation of reading the first parsing instruction at the second address and determining whether the first parsing instruction is a push instruction.

[0062] As an optional implementation, in the second aspect of the present invention, the push determination module determines whether the first parsed instruction is a push instruction in a manner that specifically includes:

[0063] Analyze the first parsing instruction to obtain an analysis result corresponding to the first parsing instruction, and determine whether the analysis result includes a predetermined feature code;

[0064] When it is determined that the analysis result includes the feature code, determining that the first parsing instruction is a push instruction;

[0065] When it is determined that the analysis result does not include the feature code, determining that the first parsed instruction is not a push instruction;

[0066] And, the device further comprises:

[0067] a second judgment module, for judging whether the jump address corresponding to the next level function of the current function is a preset task exit address when the push judgment module judges that the second parsed instruction is the push instruction and after the first judgment module judges that the third address is equal to the jump address and before the determination module determines the next level function of the current function as a new current function;

[0068] The determination module is further used to determine that the jump address corresponding to the next-level function of the current function stores a jump instruction for jumping from the next-level function of the current function to the post-call function corresponding to the next-level function of the current function when the second determination module determines that the jump address corresponding to the next-level function of the current function is not the preset task exit address, and trigger the execution of the operation of determining the next-level function of the current function as the new current function;

[0069] An exit module is used to exit the stack backtracking interface when the second judgment module determines that the jump address corresponding to the next-level function is the preset task exit address.

[0070] As an optional implementation, in the second aspect of the present invention, the determination module is further used to determine, according to the first parsing instruction, an instruction list corresponding to the first parsing instruction after determining the second address as the upper boundary of the current function corresponding to the target stack frame when the first determination module determines that the first parsing instruction has triggered the return register to complete pushing;

[0071] The device also includes:

[0072] an analysis module, configured to analyze the instruction list determined by the determination module, and obtain a first quantity corresponding to a first setting parameter and a second quantity corresponding to a second setting parameter in the instruction list, wherein the first setting parameter is a parameter in a preset bit state among all bits included in the instruction list, and the second setting parameter is a parameter in a preset bit position interval and in the preset bit state among all bits included in the instruction list;

[0073] The determination module is further configured to determine a stack length corresponding to the first parsed instruction according to the first number and a preset register width;

[0074] The determining module is further configured to determine a stack offset corresponding to the return register according to the second number and the preset register width;

[0075] The determination module is also used to determine the value of the return register based on the stack length, the stack offset and the determined value of the top register of the current function. The value of the return register is used to calculate the value of the program running address corresponding to the previous level function stack frame of the current function. The value of the program running address corresponding to the previous level function stack frame of the current function is used to determine the jump address corresponding to the next level function.

[0076] As an optional implementation, in the second aspect of the present invention, the determination module determines the first legal instruction length according to a preset first instruction length detection algorithm in a manner that specifically includes:

[0077] According to a preset first instruction length detection algorithm, the first preset length is shifted toward the lower address direction based on the determined reference address to obtain a first pending instruction;

[0078] Determine the running architecture type corresponding to the current stack backtrace, and determine the instruction set state according to the running architecture type, wherein the running architecture type corresponds to at least one instruction set state, and each instruction set state corresponds to at least one instruction length;

[0079] According to the instruction lengths respectively corresponding to each of the instruction set states, determining whether the instruction length of the first pending instruction is one of the instruction lengths corresponding to all the instruction set states;

[0080] When it is determined that the instruction length of the first pending instruction is not any instruction length corresponding to all the instruction set states, determining the second preset length as the first legal instruction length;

[0081] When it is determined that the instruction length of the first pending instruction is one of the instruction lengths corresponding to all the instruction set states, the first preset length is determined to be a first legal instruction length.

[0082] As an optional implementation, in the second aspect of the present invention, when the target stack frame is the first-level stack frame, the manner in which the determination module determines the stack frame parameters corresponding to the target stack frame of the current function specifically includes:

[0083] Calling a backtrace function according to a preset stack backtrace start instruction, and judging whether the currently running target function is an exception handling function according to the backtrace function, wherein the backtrace function is a function for starting a stack backtrace process;

[0084] When it is determined that the target function is the exception handling function, the determined exception stack is called to obtain the program running address corresponding to the exception information and the value corresponding to the stack top register as the stack frame parameter corresponding to the target stack frame of the current function;

[0085] When it is determined that the function to be processed is not the exception handling function, determining a designated task to be backtraced, and obtaining stack frame parameters corresponding to the designated task, determining the function where the stack frame parameters corresponding to the designated task are located as the current function, and determining the stack frame parameters corresponding to the designated task as stack frame parameters corresponding to the target stack frame of the current function; the designated task is a currently running task or a non-currently running task;

[0086] Wherein, obtaining the stack frame parameters corresponding to the specified task includes:

[0087] When the designated task is the currently running task, obtaining the program running address corresponding to the current CPU and the value corresponding to the stack top register according to the preset assembler as the stack frame parameters corresponding to the designated task;

[0088] When the designated task is the non-currently running task, the program running address and the value of the stack top register are extracted from the context information corresponding to the designated task as stack frame parameters corresponding to the designated task.

[0089] The third aspect of the present invention discloses another variable-length instruction set system stack backtracking implementation device, the device comprising:

[0090] A memory storing executable program code;

[0091] a processor coupled to the memory;

[0092] The processor calls the executable program code stored in the memory to execute the variable-length instruction set system stack backtracing implementation method disclosed in the first aspect of the present invention.

[0093] The fourth aspect of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called, they are used to execute the implementation method of variable-length instruction set system stack backtracing disclosed in the first aspect of the present invention.

[0094] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:

[0095] In an embodiment of the present invention, a method for implementing stack backtracing of a variable-length instruction set system is provided, the method comprising: determining stack frame parameters corresponding to a target stack frame of a current function, the stack frame parameters corresponding to the target stack frame comprising a first address corresponding to the target stack frame, the first address being a program running address corresponding to the target stack frame, the target stack frame being a first-level stack frame or a non-first-level stack frame; determining a first legal instruction length according to a preset first instruction length detection algorithm, offsetting the first legal instruction length in a low-address direction as a reference to a determined reference address to obtain a second address; the initially determined reference address is the first address; reading a first parsed instruction at the second address, and determining whether the first parsed instruction is a push instruction, and when determining that the first parsed instruction is a push instruction, determining whether the first parsed instruction has triggered a return register to complete the push, and when determining When it is determined that the first parsing instruction has triggered the return register to complete the stacking, the second address is determined as the upper boundary of the current function corresponding to the target stack frame; according to the preset second instruction length detection algorithm, the second legal instruction length is determined, and the second legal instruction length is offset in the high address direction based on the second address to obtain the third address; the second parsing instruction at the third address is read, and it is determined whether the second parsing instruction is a stacking instruction. When it is determined that the second parsing instruction is a stacking instruction, it is determined whether the third address is equal to the jump address corresponding to the current function. The jump address corresponding to the current function stores the jump instruction from the current function to the next level function; when it is determined that the third address is equal to the jump address, the next level function is determined as the new current function, and the above-mentioned operation of determining the stack frame parameters corresponding to the target stack frame of the current function is triggered. It can be seen that the implementation of the present invention can automatically determine the stack frame parameters and legal instruction length corresponding to the function that currently needs to perform a stack backtrace operation, and then read the correct instruction to be parsed in the preset backtrace direction, which improves the accuracy of reading instructions to a certain extent; further, after determining that the instruction is a push instruction and determining that the instruction triggers the push of the return register, the upper boundary of the current function can be automatically determined according to the push of the return register, which is beneficial to improving the efficiency and accuracy of determining the value of the top register of the previous level function when the stack backtrace process is subsequently executed; in addition, through a complete stack backtrace process, before determining that the third address is a jump address, the stack backtrace is automatically repeated until the next level function is determined as the new current function after determining that the third address is a jump address. The stack backtrace process does not depend on any compilation options, does not need to introduce additional overhead, and is more suitable for variable-length instruction set systems, improves the backtrace efficiency and backtrace accuracy of the stack backtrace, and solves the problem of high usage limitations in existing stack backtrace methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0096] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0097] Figure 1 It is a flow chart of a method for implementing stack backtracing of a variable-length instruction set system disclosed in an embodiment of the present invention;

[0098] Figure 2 It is a flow chart of another method for implementing stack backtracing of a variable-length instruction set system disclosed in an embodiment of the present invention;

[0099] Figure 3 It is a structural schematic diagram of a device for implementing stack backtracing of a variable-length instruction set system disclosed in an embodiment of the present invention;

[0100] Figure 4 It is a structural schematic diagram of another variable-length instruction set system stack backtracing implementation device disclosed in an embodiment of the present invention;

[0101] Figure 5 It is a structural schematic diagram of another variable-length instruction set system stack backtracing implementation device disclosed in an embodiment of the present invention;

[0102] Figure 6 It is a flow chart of another method for implementing stack backtracing of a variable-length instruction set system disclosed in an embodiment of the present invention. DETAILED DESCRIPTION

[0103] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0104] The terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish different objects rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, device, product or end including a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or ends.

[0105] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0106] The present invention discloses a method and device for implementing stack backtracking of a variable-length instruction set system, which can automatically determine the stack frame parameters and legal instruction length corresponding to the function that currently needs to perform a stack backtracking operation, and then read the correct instruction to be parsed in the preset backtracking direction, thereby improving the accuracy of reading the instruction to a certain extent; further, after determining that the instruction is a stack push instruction and determining that the instruction triggers the return register to be pushed, the upper boundary of the current function can be automatically determined according to the return register push, which is conducive to improving the efficiency and accuracy of determining the value of the top register of the upper-level function stack when the stack backtracking process is subsequently executed; in addition, through a complete stack backtracking process, before determining that the third address is a jump address, the stack backtracking is automatically repeated until the next-level function is determined as the new current function after determining that the third address is a jump address, the stack backtracking process does not rely on any compilation options, does not need to introduce additional overhead, and is more applicable to variable-length instruction set systems, improves the backtracking efficiency and backtracking accuracy of the stack backtracking, and solves the problem of high usage limitations in the existing stack backtracking means. The following are described in detail.

[0107] Embodiment 1

[0108] See also Figure 1 as well as Figure 6 , Figure 1 and Figure 6 1 is a flow chart of a method for implementing stack backtracing of a variable-length instruction set system disclosed in an embodiment of the present invention. Figure 1 and Figure 6 The implementation method of variable-length instruction set system stack backtracking described above can be applied to a variable-length instruction set system stack backtracking implementation device, and the embodiment of the present invention does not limit this. Figure 1 and Figure 6 As shown, the implementation method of the variable-length instruction set system stack backtracking may include the following operations:

[0109] 101. Determine the stack frame parameters corresponding to the target stack frame of the current function.

[0110] In the embodiment of the present invention, the stack frame parameters corresponding to the target stack frame include a first address corresponding to the target stack frame, the first address is a program running address corresponding to the target stack frame, and the target stack frame is a first-level stack frame or a non-first-level stack frame.

[0111] In the embodiment of the present invention, optionally, the stack frame parameter also includes the value of the stack top register of the target stack frame;

[0112] When the target stack frame is not a first-level stack frame, the stack frame parameters corresponding to the target stack frame can be determined in the following way:

[0113] Calculate the value of the top register of the target stack frame of the current function according to the total push length corresponding to the previous level function of the current function and the value of the top register corresponding to the previous level function of the current function; wherein the total push length corresponding to the previous level function of the current function is determined according to the push length of each push instruction corresponding to the previous level function of the current function; wherein the previous level function of the current function is the function that has been most recently backtraced before the current function;

[0114] Based on the stack offset corresponding to the return register when running the previous level function of the current function, the value of the top of the stack register corresponding to the previous level function of the current function, and the total push length corresponding to the previous level function of the current function, determine the value of the return register when running the previous level function of the current function, and calculate the first address corresponding to the target stack frame of the current function based on the value of the return register when running the previous level function of the current function and the predetermined jump instruction length.

[0115] In the embodiment of the present invention, it should be noted that the above-mentioned previous-level function and next-level function are defined relative to the stack backtracing direction in the stack backtracing process, and are unrelated to the actual corresponding function addresses of each function and are also unrelated to the calling relationship of each function in the actual application. That is, when function A is the function currently being backtraced, and function B is the most recently backtraced function before backtracing function A, then function B is called the previous-level function of function A. Similarly, after backtracing function A, if function C is to be continued to be backtraced, function C is called the next-level function of function A. It can be adaptively adjusted in actual applications and is not limited by the embodiment of the present invention.

[0116] It should be noted that, in the embodiment of the present invention, for ease of understanding, the above-mentioned method of calculating the value of the top register of the current function target stack frame, determining the value of the return register when running the previous level function of the current function, and calculating the first address corresponding to the current function target stack frame is illustrated by way of example:

[0117] Among them, the value of the stack top register of the current function target stack frame (recorded as SP1) = the value of the stack top register corresponding to the previous level function of the current function (recorded as SP2) + the push length of the push instruction corresponding to the previous level function of the current function;

[0118] The value of the return register (recorded as LR1) = the value of the top register of the current function corresponding to SP1 + the instruction push length of the push instruction corresponding to the current function - the stack offset of the return register (recorded as LR2);

[0119] The first address corresponding to the current function target stack frame (recorded as PC1) = the value of the return register LR1-jump instruction length;

[0120] Further, assuming SP2 = 0x40800000, it is determined that in the instruction list corresponding to the first parsed instruction, the number of push instructions is 6, and the default width of the general register corresponding to each push instruction is 4 bits, then the push length of the push instruction corresponding to the current function = 6*4 = 24 (24 corresponds to 0x18 in hexadecimal); it is determined that the number of 1s in the binary system in bits 0-13 in the instruction list is 4, and the default width of each general register is 4 bits, then the stack offset LR2 of the return register is 4*4 = 16 (16 in hexadecimal is 0x10); it can be determined that the address for saving the value of the return register is: LR1 = 0x40800000 + 0x18 - 0x10 = 0x40800004;

[0121] Assuming that the jump instruction length is 4 bits, PC1=LR1-4bit=0x40800004-4=0x40800000, which is not limited in the embodiment of the present invention.

[0122] It can be seen that in an embodiment of the present invention, for the case where the target stack frame is not a first-level stack frame, a calculation scheme is provided for calculating the value of the top register of the target stack frame of the current function by using the total length of the stack corresponding to the previous-level function of the current function and the value of the top register; at the same time, a calculation method is also provided for calculating the first address corresponding to the target stack frame of the current function by determining the value of the return register and the predetermined jump instruction length; when implementing different types of target stack frames, the calculation method of the stack frame parameters can be adaptively adjusted, thereby improving the accuracy of the determined stack frame parameters and, to a certain extent, improving the backtracing accuracy of the subsequent stack backtracing process.

[0123] In the embodiment of the present invention, optionally, when the target stack frame is a first-level stack frame, determining the stack frame parameters corresponding to the target stack frame of the current function includes:

[0124] Calling a backtrace function according to a preset stack backtrace start instruction, and judging whether the currently running target function is an exception handling function according to the backtrace function, the backtrace function is a function that starts a stack backtrace process;

[0125] When it is determined that the target function is an exception handling function, the determined exception stack is called to obtain the program running address corresponding to the exception information and the value corresponding to the stack top register as the stack frame parameter corresponding to the target stack frame of the current function;

[0126] When it is determined that the function to be processed is not an exception handling function, a designated task to be backtraced is determined, and a stack frame parameter corresponding to the designated task is obtained, a function where the stack frame parameter corresponding to the designated task is located is determined as the current function, and the stack frame parameter corresponding to the designated task is determined as the stack frame parameter corresponding to the target stack frame of the current function; the designated task is a currently running function or a non-currently running function;

[0127] Among them, obtaining the stack frame parameters corresponding to the specified task includes:

[0128] When the specified task is the currently running function, the program running address corresponding to the current CPU and the value corresponding to the stack top register are obtained according to the preset assembler as the stack frame parameters corresponding to the specified task;

[0129] When the designated task is not a currently running function, the program running address and the value of the stack top register are extracted from the context information corresponding to the designated task as stack frame parameters corresponding to the designated task.

[0130] It can be seen that in the embodiment of the present invention, after calling the backtrace function, the function type of the backtrace function can be automatically determined (determined whether it is an exception handling function), and a matching judgment operation is performed according to the judgment result: when it is judged to be yes, the stack frame parameters are obtained through the exception stack; when it is judged to be no, the stack frame parameters of the specified task are obtained after determining the specified task to be backtraced; a method for adaptively adjusting the stack frame parameters is implemented, thereby improving the determination efficiency and accuracy of the stack frame parameters.

[0131] 102. Determine a first legal instruction length according to a preset first instruction length detection algorithm.

[0132] In the embodiment of the present invention, the method of determining the first legal instruction length in step 102 according to the preset first instruction length detection algorithm may specifically include the following operations:

[0133] According to a preset first instruction length detection algorithm, the first preset length is shifted toward the lower address direction based on the determined reference address to obtain a first pending instruction;

[0134] Determine the running architecture type corresponding to the current stack backtrace, and determine the instruction set state according to the running architecture type, the running architecture type corresponds to at least one instruction set state, and each instruction set state corresponds to at least one instruction length;

[0135] According to the instruction lengths corresponding to each instruction set state, determining whether the instruction length of the first pending instruction is one of the instruction lengths corresponding to all instruction set states;

[0136] When it is determined that the instruction length of the first pending instruction is not any instruction length corresponding to all instruction set states, determining the second preset length as the first legal instruction length;

[0137] When it is determined that the instruction length of the first pending instruction is one of the instruction lengths corresponding to all instruction set states, the first preset length is determined to be the first legal instruction length.

[0138] In the embodiment of the present invention, it should be noted that the above-mentioned operating architecture type includes ARM type or RISC-V type; wherein, when the operating architecture type is ARM type, the instruction set state includes ARM state and / or Thumb state.

[0139] It can be seen that in the embodiment of the present invention, when determining the first legal instruction length, it is possible to determine the corresponding instruction set state and the instruction length corresponding to the instruction set state according to different operating architecture types, thereby determining the first preset length according to the instruction lengths of different instruction set states, thereby improving the accuracy of the determined first preset length, thereby improving the accuracy of determining the first pending instruction.

[0140] 103. Using the determined reference address as a reference, shift the first legal instruction length toward a lower address to obtain a second address.

[0141] In the embodiment of the present invention, the initially determined reference address is the first address.

[0142] 104. Read the first parsed instruction at the second address, and determine whether the first parsed instruction is a push instruction.

[0143] In the embodiment of the present invention, when the judgment result of step 104 is yes, step 105 is executed; optionally, when the judgment result of step 104 is no, that is, when it is judged that the first parsed instruction is not a push instruction, the second address is determined as a new reference address, and the above-mentioned step of determining the first legal instruction length according to the preset instruction length detection algorithm is re-executed, and the first legal instruction length is offset in the direction of the lower address based on the determined reference address to obtain the second address, and the above-mentioned step of reading the first parsed instruction at the second address and determining whether the first parsed instruction is a push instruction is executed;

[0144] Furthermore, the above method of determining whether the first parsed instruction is a push instruction may specifically include the following operations:

[0145] Analyze the first parsing instruction, obtain an analysis result corresponding to the first parsing instruction, and determine whether the analysis result includes a predetermined feature code;

[0146] When it is determined that the analysis result includes the feature code, determining that the first parsing instruction is a push instruction;

[0147] When it is determined that the analysis result does not include the feature code, determining that the first parsed instruction is not a push instruction;

[0148] Furthermore, after determining that the third address is equal to the jump address and before determining the next level function of the current function as the new current function, the method further includes:

[0149] Determine whether the jump address corresponding to the next level function of the current function is the preset task exit address. When it is determined that the jump address corresponding to the next level function of the current function is not the preset task exit address, determine that the jump address corresponding to the next level function of the current function stores a jump instruction for jumping from the next level function of the current function to the post-call function corresponding to the next level function of the current function, and trigger the execution of the above-mentioned operation of determining the next level function of the current function as the new current function;

[0150] When it is determined that the jump address corresponding to the next-level function is the preset task exit address, the stack backtracking interface is exited.

[0151] It can be seen that in the embodiment of the present invention, determining whether the first parsed instruction is a push instruction through a feature code is beneficial to improving the efficiency and accuracy of determining the push instruction; in addition, before determining the next-level function as the new current function, it will be determined whether the jump address corresponding to the next-level function is the preset task exit address. If so, the stack backtracing interface is exited to end the current stack backtracing process, and a step for ending the stack backtracing process is set to prevent the stack backtracing operation from being repeated after the stack backtracing process is completed, which may cause the program to freeze and fail. To a certain extent, the stack backtracing process is optimized and the stack backtracing success rate is improved.

[0152] 105. When it is determined that the first parsed instruction is a push instruction, determine whether the first parsed instruction has triggered a return register to complete the push.

[0153] In an embodiment of the present invention, when the judgment result of step 105 is yes, step 106 is executed; optionally, when the judgment result of step 105 is no, that is, when it is judged that the first parsed instruction is a push instruction, and it is judged that the first parsed instruction does not trigger the return register to complete the push, the second address is determined as the new reference address, and the above-mentioned step of determining the first legal instruction length according to the preset instruction length detection algorithm is re-executed, and the first legal instruction length is offset toward the lower address based on the determined reference address to obtain the step corresponding to the second address, and the above-mentioned step of reading the first parsed instruction at the second address and judging whether the first parsed instruction is a push instruction is executed.

[0154] 106. When it is determined that the first parsing instruction has triggered the return register to complete pushing, the second address is determined as the upper boundary of the current function corresponding to the target stack frame.

[0155] 107. Determine a second legal instruction length according to a preset second instruction length detection algorithm.

[0156] In the embodiment of the present invention, optionally, the method of determining the second legal instruction length according to the preset second instruction length detection algorithm may specifically include the following operations:

[0157] According to a preset second instruction length detection algorithm, the first preset length is offset toward the higher address direction based on the second address to obtain a second pending instruction;

[0158] According to the instruction lengths corresponding to each instruction set state, determining whether the instruction length of the second pending instruction is one of the instruction lengths corresponding to all instruction set states;

[0159] When it is determined that the instruction length of the second pending instruction is not any instruction length corresponding to all instruction set states, determining the second preset length as the second legal instruction length;

[0160] When it is determined that the instruction length of the second pending instruction is one of the instruction lengths corresponding to all instruction set states, the first preset length is determined to be the second legal instruction length.

[0161] 108. Using the second address as a reference, offset the second legal instruction length toward a higher address to obtain a third address.

[0162] 109. Read the second parsed instruction at the third address, and determine whether the second parsed instruction is a push instruction.

[0163] 110. When it is determined that the second parsed instruction is a push instruction, determine whether the third address is equal to the jump address corresponding to the current function.

[0164] In the embodiment of the present invention, the jump address corresponding to the current function stores a jump instruction for jumping from the current function to a post-call function, where the post-call function is a function whose function calling sequence is after the function calling sequence of the current function.

[0165] 111. When it is determined that the third address is equal to the jump address, the next level function of the current function is determined as a new current function.

[0166] It can be seen that implementation Figure 1 and Figure 6 The described variable-length instruction set system stack backtracing implementation method can automatically determine the stack frame parameters and legal instruction length corresponding to the function that currently needs to perform a stack backtracing operation, and then read the correct instruction to be parsed in the preset backtracing direction, thereby improving the accuracy of reading the instruction to a certain extent; further, after determining that the instruction is a stack push instruction and determining that the instruction triggers the return register to be pushed, the upper boundary of the current function can be automatically determined according to the return register push, which is conducive to improving the efficiency and accuracy of determining the value of the top register of the previous level function when the stack backtracing process is subsequently executed; in addition, through a complete stack backtracing process, before determining that the third address is a jump address, the stack backtracing is automatically repeated until the next level function is determined as the new current function after determining that the third address is a jump address. The stack backtracing process does not depend on any compilation options, does not need to introduce additional overhead, and is more suitable for variable-length instruction set systems, thereby improving the backtracing efficiency and backtracing accuracy of the stack backtracing, and at the same time solving the problem of high usage limitations in existing stack backtracing means.

[0167] In an optional embodiment, when it is determined that the jump address corresponding to the next-level function is not the preset task exit address, after determining that the jump address corresponding to the next-level function stores a jump instruction for jumping from the next-level function of the current function to the post-call function corresponding to the next-level function of the current function, and before triggering the execution of the above operation of determining the next-level function of the current function as the new current function, the implementation method of the variable-length instruction set system stack backtracking may further include the following operations:

[0168] Determine whether an instruction set state switch occurs in the next level function of the above current function, and when it is determined that the instruction set state switch does not occur in the above next level function, trigger the execution of the above operation of determining the next level function of the current function as the new current function;

[0169] When it is determined that an instruction set state switch occurs in the next level function of the above current function, according to the operation architecture type corresponding to the next level function of the current function, the target instruction set state corresponding to the operation architecture type and the target instruction length corresponding to the target instruction set state are determined;

[0170] The target instruction set state is determined as the new instruction set state corresponding to the execution stack backtrace of the next level function of the current function, and the target instruction length is determined as the new instruction length corresponding to the execution stack backtrace of the next level function of the current function, and the above-mentioned operation of determining the next level function of the current function as the new current function is triggered.

[0171] It can be seen that in this optional embodiment, before backtracing to a new function, it can automatically determine whether the instruction set state has switched, and execute matching operations based on the determination result, thereby realizing dynamic switching of the instruction set state and improving the backtracing accuracy and reliability of the stack backtracing process.

[0172] Embodiment 2

[0173] See also Figure 2 , Figure 2 It is a flow chart of another implementation method of variable length instruction set system stack backtracking disclosed in an embodiment of the present invention. Figure 2 The implementation method of variable-length instruction set system stack backtracking described above can be applied to a variable-length instruction set system stack backtracking implementation device, and the embodiment of the present invention does not limit this. Figure 2 As shown, the implementation method of the variable-length instruction set system stack backtracking may include the following operations:

[0174] 201. Determine the stack frame parameters corresponding to the target stack frame of the current function.

[0175] 202. Determine a first legal instruction length according to a preset first instruction length detection algorithm.

[0176] 203. Using the determined reference address as a reference, shift the first legal instruction length toward a lower address to obtain a second address.

[0177] 204. Read the first parsed instruction at the second address, and determine whether the first parsed instruction is a push instruction.

[0178] 205. When it is determined that the first parsed instruction is a push instruction, determine whether the first parsed instruction has triggered a return register to complete the push.

[0179] 206. When it is determined that the first parsing instruction has triggered the return register to complete pushing, the second address is determined as the upper boundary of the current function corresponding to the target stack frame.

[0180] 207. Determine, according to the first parsing instruction, an instruction list corresponding to the first parsing instruction.

[0181] 208. Analyze the instruction list to obtain a first quantity corresponding to a first setting parameter and a second quantity corresponding to a second setting parameter in the instruction list.

[0182] In the embodiment of the present invention, the first setting parameter is a parameter in a preset bit state among all bits included in the instruction list, and the second setting parameter is a parameter in a preset bit position interval and in a preset bit state among all bits included in the instruction list.

[0183] It should be noted that the preset bit state may be binary 0 or binary 1, and the preset bit position interval may be the bit interval corresponding to the 0th to 13th bits in the instruction list, which is not limited in the embodiment of the present invention.

[0184] 209. Determine a stack length corresponding to the first parsed instruction according to the first number and a preset register width.

[0185] 210. Determine a stack offset corresponding to the return register according to the second number and a preset register width.

[0186] 211. Determine the value of the return register according to the stack length, the stack offset, and the determined value of the top stack register of the current function.

[0187] In an embodiment of the present invention, the value of the return register is used to calculate the value of the program running address corresponding to the previous level function stack frame of the current function, and the value of the program running address corresponding to the previous level function stack frame of the current function is used to determine the jump address corresponding to the next level function.

[0188] 212. Determine a second legal instruction length according to a preset second instruction length detection algorithm.

[0189] 213. Using the second address as a reference, offset the second legal instruction length toward a higher address to obtain a third address.

[0190] 214. Read the second parsed instruction at the third address, and determine whether the second parsed instruction is a push instruction.

[0191] 215. When it is determined that the second parsed instruction is a push instruction, determine whether the third address is equal to the jump address corresponding to the current function.

[0192] 216. When it is determined that the third address is equal to the jump address, the next level function of the current function is determined as a new current function.

[0193] In the embodiment of the present invention, for other descriptions of steps 201 to 206 and steps 212 to 216, please refer to other specific descriptions of steps 101 to 106 and steps 107 to 111 in the first embodiment, which will not be repeated in the embodiment of the present invention.

[0194] It can be seen that implementation Figure 2The described variable-length instruction set system stack backtracing implementation method can intelligently determine the first number of first set parameters and the second number corresponding to the second set parameters after determining the corresponding instruction list based on the first parsing instruction, thereby automatically calculating the push length of the first parsing instruction and the push offset of the return register, and then the stack length and the stack offset are used to determine the value of the return register, and the value of the return register is used to subsequently calculate the value of the program running address corresponding to the previous level function stack frame, wherein the value of the program running address corresponding to the previous level function stack frame is used to determine the jump address corresponding to the next level function, which is beneficial to improving the jump to the correct address when jumping to the next level function in the stack backtracing process, and improving the accuracy and reliability of the stack backtracing.

[0195] Embodiment 3

[0196] See also Figure 3 , Figure 3 This is a schematic diagram of the structure of a variable-length instruction set system stack backtracking implementation device disclosed in an embodiment of the present invention. The variable-length instruction set system stack backtracking implementation device can be applied to RISC-V chips or ARM chips, and the embodiment of the present invention does not limit this. Figure 3 As shown, the variable-length instruction set system stack backtracing implementation device may include a determination module 301, an addressing module 302, a stack push determination module 303 and a first determination module 304, wherein:

[0197] Determination module 301 is used to determine the stack frame parameters corresponding to the target stack frame of the current function. The stack frame parameters corresponding to the target stack frame include a first address corresponding to the target stack frame. The first address is a program running address corresponding to the target stack frame. The target stack frame is a first-level stack frame or a non-first-level stack frame.

[0198] The addressing module 302 is used to determine the first legal instruction length according to a preset first instruction length detection algorithm, and to offset the first legal instruction length toward a lower address based on the determined reference address to obtain a second address; the initially determined reference address is the first address.

[0199] The push determination module 303 is used to read the first parsed instruction at the second address and determine whether the first parsed instruction is a push instruction.

[0200] The first judgment module 304 is used to judge whether the first parsed instruction has triggered the return register to complete the stacking when the stacking judgment module 303 judges that the first parsed instruction is a stacking instruction.

[0201] The determination module 301 is further configured to determine the second address obtained by the addressing module 302 as the upper boundary of the current function corresponding to the target stack frame when the first determination module 304 determines that the first parsed instruction has triggered the return register to complete the stacking.

[0202] The addressing module 302 is further used to determine the second legal instruction length according to a preset second instruction length detection algorithm, and to shift the second legal instruction length toward a higher address based on the second address to obtain a third address.

[0203] The push determination module 303 is further configured to read the second parsed instruction at the third address and determine whether the second parsed instruction is a push instruction.

[0204] The first judgment module 304 is also used to judge whether the third address is equal to the jump address corresponding to the current function when the push judgment module 303 judges that the second parsing instruction is a push instruction. The jump address corresponding to the current function stores a jump instruction from the current function to the post-call function. The post-call function is a function whose function calling order is after the function calling order of the current function.

[0205] The determination module 301 is also used to determine the next-level function of the current function as the new current function when the push judgment module 303 determines that the second parsing instruction is a push instruction and the first judgment module 304 determines that the third address is equal to the jump address, and trigger the execution of the above-mentioned operation of determining the stack frame parameters corresponding to the target stack frame of the current function.

[0206] It can be seen that implementation Figure 3 The described variable-length instruction set system stack backtracing implementation device can automatically determine the stack frame parameters and legal instruction length corresponding to the function that currently needs to perform the stack backtracing operation, and then read the correct instruction to be parsed in the preset backtracing direction, which improves the accuracy of reading the instruction to a certain extent; further, after determining that the instruction is a stack push instruction and determining that the instruction triggers the return register to be pushed, the upper boundary of the current function can be automatically determined according to the return register push, which is conducive to improving the efficiency and accuracy of determining the value of the top register of the previous level function when the stack backtracing process is subsequently executed; in addition, through a complete stack backtracing process, before determining that the third address is a jump address, the stack backtracing is automatically repeated until the next level function is determined as the new current function after determining that the third address is a jump address. The stack backtracing process does not depend on any compilation options, does not need to introduce additional overhead, and is more suitable for variable-length instruction set systems, improves the backtracing efficiency and backtracing accuracy of the stack backtracing, and solves the problem of high usage limitations in existing stack backtracing means.

[0207] In an optional embodiment, the determination module 301 is also used to determine the second address as a new reference address when the push judgment module 303 determines that the first parsed instruction is not a push instruction, and trigger the addressing module 302 to re-execute the above-mentioned operation of determining the first legal instruction length according to the preset instruction length detection algorithm, offsetting the first legal instruction length in the lower address direction based on the determined reference address to obtain the second address, and triggering the push judgment module 303 to execute the above-mentioned operation of reading the first parsed instruction at the second address and determining whether the first parsed instruction is a push instruction.

[0208] The determination module 301 is also used to determine the second address as the new reference address when the push judgment module 303 determines that the first parsed instruction is a push instruction, and the first judgment module 304 determines that the first parsed instruction does not trigger the return register to complete the push, and trigger the addressing module 302 to re-execute the above-mentioned detection algorithm based on the preset instruction length, determine the first legal instruction length, and offset the first legal instruction length in the low address direction based on the determined reference address to obtain the operation corresponding to the second address, and trigger the push judgment module 303 to execute the above-mentioned operation of reading the first parsed instruction at the second address and judging whether the first parsed instruction is a push instruction.

[0209] It can be seen that in this optional embodiment, in order to determine that the first parsed instruction is not a push instruction or the first parsed instruction does not trigger the return register to complete the push, a loop process is set up, and the addressing module 302 is re-triggered to execute the above-mentioned detection algorithm based on the preset instruction length to determine the first legal instruction length, and to offset the first legal instruction length in the low address direction based on the determined reference address to obtain the operation corresponding to the second address, and the push judgment module 303 is triggered to execute the above-mentioned operation of reading the first parsed instruction at the second address and judging whether the first parsed instruction is a push instruction, thereby achieving the process optimization of stack backtracing and improving the backtracing integrity and backtracing reliability of the stack backtracing process.

[0210] In this optional embodiment, further optionally, the push determination module 303 determines whether the first parsed instruction is a push instruction in a manner specifically including:

[0211] Analyze the first parsing instruction, obtain an analysis result corresponding to the first parsing instruction, and determine whether the analysis result includes a predetermined feature code;

[0212] When it is determined that the analysis result includes the feature code, determining that the first parsing instruction is a push instruction;

[0213] When it is determined that the analysis result does not include the feature code, determining that the first parsed instruction is not a push instruction;

[0214] And, if Figure 4As shown, the device may further include a second judgment module 305 and an exit module 306, wherein:

[0215] The second judgment module 305 is used to judge whether the jump address corresponding to the next-level function of the current function is the preset task exit address when the push judgment module 303 judges that the second parsed instruction is a push instruction, and after the first judgment module 304 judges that the third address is equal to the jump address, and before the determination module 301 determines the next-level function of the current function as the new current function.

[0216] The determination module 301 is also used to determine that the jump address corresponding to the next-level function of the current function stores a jump instruction of a post-calling function from the next-level function of the current function to the next-level function of the current function when the second judgment module 305 determines that the jump address corresponding to the next-level function of the current function is not the preset task exit address, and trigger the execution of the above-mentioned operation of determining the next-level function of the current function as the new current function.

[0217] The exit module 306 is used to exit the stack backtracking interface when the second judgment module 305 judges that the jump address corresponding to the next-level function is the preset task exit address.

[0218] It can be seen that implementation Figure 4 The described variable-length instruction set system stack backtracing implementation device determines whether the first parsed instruction is a push instruction through a feature code, which is beneficial to improving the efficiency and accuracy of determining the push instruction; in addition, before determining the next-level function as the new current function, it will determine whether the jump address corresponding to the next-level function is the preset task exit address. If so, the stack backtracing interface is exited to end the current stack backtracing process, and a step for ending the stack backtracing process is set to prevent the stack backtracing operation from being repeated after the stack backtracing process is completed, causing the program to become stuck and erroneous. To a certain extent, the stack backtracing process is optimized and the stack backtracing success rate is improved.

[0219] In another optional embodiment, the stack frame parameters also include the value of the top register of the target stack frame; wherein, when the target stack frame is not a first-level stack frame, the stack frame parameters corresponding to the target stack frame are determined in the following manner:

[0220] Calculate the value of the top register of the target stack frame of the current function according to the total push length corresponding to the previous level function of the current function and the value of the top register corresponding to the previous level function of the current function; wherein the total push length corresponding to the previous level function of the current function is determined according to the push length of each push instruction corresponding to the previous level function of the current function; wherein the previous level function of the current function is the function that has been most recently backtraced before the current function;

[0221] Based on the stack offset corresponding to the return register when running the previous level function of the current function, the value of the top of the stack register corresponding to the previous level function of the current function, and the total push length corresponding to the previous level function of the current function, determine the value of the return register when running the previous level function of the current function, and calculate the first address corresponding to the target stack frame of the current function based on the value of the return register when running the previous level function of the current function and the predetermined jump instruction length.

[0222] It can be seen that implementation Figure 4 The described variable-length instruction set system stack backtracing implementation device provides, for the case where the target stack frame is not a first-level stack frame, a calculation scheme for calculating the value of the top register of the target stack frame of the current function by using the total length of the stack pushed corresponding to the previous-level function of the current function and the value of the top register; it also provides a calculation method for calculating the first address corresponding to the target stack frame of the current function by determining the value of the return register and a predetermined jump instruction length; when implementing different types of target stack frames, it can adaptively adjust the calculation method of the stack frame parameters, thereby improving the accuracy of the determined stack frame parameters and, to a certain extent, improving the backtracing accuracy of the subsequent stack backtracing process.

[0223] In another optional embodiment, the determination module 301 is also used to determine the instruction list corresponding to the first parsing instruction according to the first parsing instruction after determining the second address as the upper boundary of the current function corresponding to the target stack frame when the first judgment module 304 determines that the first parsing instruction has triggered the return register to complete pushing.

[0224] And, if Figure 4 As shown, the device may further include an analysis module 307, wherein:

[0225] The analysis module 307 is used to analyze the instruction list determined by the determination module 301 to obtain a first quantity corresponding to a first setting parameter in the instruction list and a second quantity corresponding to a second setting parameter, wherein the first setting parameter is a parameter in a preset bit state among all bits included in the instruction list, and the second setting parameter is a parameter in a preset bit position interval and in a preset bit state among all bits included in the instruction list.

[0226] The determination module 301 is further configured to determine a stack length corresponding to the first parsed instruction according to the first number and a preset register width.

[0227] The determination module 301 is further configured to determine a stack offset corresponding to the return register according to the second number and a preset register width.

[0228] Determination module 301 is also used to determine the value of the return register based on the stack length, the stack offset and the value of the top register of the current function. The value of the return register is used to calculate the value of the program running address corresponding to the previous level function stack frame of the current function. The value of the program running address corresponding to the previous level function stack frame of the current function is used to determine the jump address corresponding to the next level function.

[0229] It can be seen that implementation Figure 4 The described variable-length instruction set system stack backtracing implementation device can, after determining the corresponding instruction list based on the first parsing instruction, intelligently determine the first number of the first setting parameter and the second number corresponding to the second setting parameter, thereby automatically calculating the push length of the first parsing instruction and the push offset of the return register, and then the stack length and the stack offset are used to determine the value of the return register, and the value of the return register is used to subsequently calculate the value of the program running address corresponding to the previous-level function stack frame, wherein the value of the program running address corresponding to the previous-level function stack frame is used to determine the jump address corresponding to the next-level function, which is beneficial to improving the jump to the correct address when jumping to the next-level function in the stack backtracing process, thereby improving the accuracy and reliability of the stack backtracing.

[0230] In another optional embodiment, the determination module 301 determines the first legal instruction length according to a preset first instruction length detection algorithm in a manner that specifically includes:

[0231] According to a preset first instruction length detection algorithm, the first preset length is shifted toward the lower address direction based on the determined reference address to obtain a first pending instruction;

[0232] Determine the running architecture type corresponding to the current stack backtrace, and determine the instruction set state according to the running architecture type, the running architecture type corresponds to at least one instruction set state, and each instruction set state corresponds to at least one instruction length;

[0233] According to the instruction lengths corresponding to each instruction set state, determining whether the instruction length of the first pending instruction is one of the instruction lengths corresponding to all instruction set states;

[0234] When it is determined that the instruction length of the first pending instruction is not any instruction length corresponding to all instruction set states, determining the second preset length as the first legal instruction length;

[0235] When it is determined that the instruction length of the first pending instruction is one of the instruction lengths corresponding to all instruction set states, the first preset length is determined to be the first legal instruction length.

[0236] It can be seen that implementation Figure 4The described variable-length instruction set system stack backtracing implementation device can, when determining the first legal instruction length, determine the corresponding instruction set state and the instruction length corresponding to the instruction set state according to different operating architecture types, thereby determining the first preset length according to the instruction lengths of different instruction set states, thereby improving the accuracy of the determined first preset length, thereby improving the accuracy of determining the first pending instruction.

[0237] In yet another optional embodiment, when the target stack frame is a first-level stack frame, the manner in which the determination module 301 determines the stack frame parameters corresponding to the target stack frame of the current function specifically includes:

[0238] Calling a backtrace function according to a preset stack backtrace start instruction, and judging whether the currently running target function is an exception handling function according to the backtrace function, the backtrace function is a function that starts a stack backtrace process;

[0239] When it is determined that the target function is an exception handling function, the determined exception stack is called to obtain the program running address corresponding to the exception information and the value corresponding to the stack top register as the stack frame parameter corresponding to the target stack frame of the current function;

[0240] When it is determined that the function to be processed is not an exception handling function, a designated task to be backtraced is determined, and a stack frame parameter corresponding to the designated task is obtained, a function where the stack frame parameter corresponding to the designated task is located is determined as the current function, and the stack frame parameter corresponding to the designated task is determined as the stack frame parameter corresponding to the target stack frame of the current function; the designated task is a currently running task or a non-currently running task;

[0241] Among them, obtaining the stack frame parameters corresponding to the specified task includes:

[0242] When the specified task is the current running task, the program running address corresponding to the current CPU and the value corresponding to the stack top register are obtained according to the preset assembler as the stack frame parameters corresponding to the specified task;

[0243] When the designated task is not the currently running task, the program running address and the value of the stack top register are extracted from the context information corresponding to the designated task as the stack frame parameters corresponding to the designated task.

[0244] It can be seen that implementation Figure 4 The described variable-length instruction set system stack backtracing implementation device can automatically determine the function type of the backtracing function (determine whether it is an exception handling function) after calling the backtracing function, and perform a matching judgment operation based on the judgment result: when the judgment is yes, the stack frame parameters are obtained through the exception stack; when the judgment is no, the stack frame parameters of the specified task are obtained after the specified task to be backtraced is determined; a method for adaptively adjusting the determination of the stack frame parameters is implemented, thereby improving the determination efficiency and accuracy of the stack frame parameters.

[0245] Embodiment 4

[0246] See also Figure 5 , Figure 5 FIG. 1 is a schematic diagram of the structure of another variable-length instruction set system stack backtracking implementation device disclosed in an embodiment of the present invention. Figure 5 As shown, the variable-length instruction set system stack backtracking implementation device may include:

[0247] A memory 401 storing executable program codes;

[0248] a processor 402 coupled to the memory 401;

[0249] The processor 402 calls the executable program code stored in the memory 401 to execute the steps in the method for implementing stack backtracing of a variable-length instruction set system described in the first embodiment of the present invention or the second embodiment of the present invention.

[0250] Embodiment 5

[0251] An embodiment of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called, they are used to execute the steps in the implementation method of variable-length instruction set system stack backtracing described in Embodiment 1 or Embodiment 2 of the present invention.

[0252] Embodiment 6

[0253] An embodiment of the present invention discloses a computer program product, which includes a non-transitory computer storage medium storing a computer program, and the computer program is operable to enable a computer to execute the steps in the implementation method of the variable-length instruction set system stack backtracing described in Embodiment 1 or Embodiment 2.

[0254] The device embodiments described above are only illustrative, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, i.e., they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative work.

[0255] Through the specific description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the above technical solution can be essentially or partly contributed to the prior art in the form of a software product, and the computer software product can be stored in a computer storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.

[0256] Finally, it should be noted that the implementation method and device of a variable-length instruction set system stack backtrace disclosed in the embodiment of the present invention discloses only a preferred embodiment of the present invention, which is only used to illustrate the technical solution of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions recorded in the aforementioned embodiments can still be modified, or some of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A method for implementing stack backtracing of a variable-length instruction set system, characterized in that: The method comprises: Determine a stack frame parameter corresponding to a target stack frame of the current function, wherein the stack frame parameter corresponding to the target stack frame includes a first address corresponding to the target stack frame, wherein the first address is a program running address corresponding to the target stack frame, and the target stack frame is a first-level stack frame or a non-first-level stack frame; According to a preset first instruction length detection algorithm, a first legal instruction length is determined, and the first legal instruction length is shifted toward a lower address direction based on the determined reference address to obtain a second address; the initially determined reference address is the first address; Reading the first parsed instruction at the second address, and determining whether the first parsed instruction is a push instruction, and when determining that the first parsed instruction is the push instruction, determining whether the first parsed instruction has triggered the return register to complete the push, and when determining that the first parsed instruction has triggered the return register to complete the push, determining the second address as the upper boundary of the current function corresponding to the target stack frame; Determine the second legal instruction length according to a preset second instruction length detection algorithm, and shift the second legal instruction length toward a higher address based on the second address to obtain a third address; Read the second parsing instruction at the third address, and determine whether the second parsing instruction is the push instruction. When it is determined that the second parsing instruction is the push instruction, determine whether the third address is equal to the jump address corresponding to the current function, the jump address corresponding to the current function stores a jump instruction for jumping from the current function to a post-calling function, and the post-calling function is a function whose function calling sequence is after the function calling sequence of the current function; when it is determined that the third address is equal to the jump address, determine the next-level function of the current function as the new current function, and trigger the execution of the operation of determining the stack frame parameters corresponding to the target stack frame of the current function; The stack frame parameters also include the value of the stack top register of the target stack frame; Wherein, when the target stack frame is the non-first-level stack frame, the stack frame parameters corresponding to the target stack frame are determined in the following manner: Calculate the value of the top register of the target stack frame of the current function according to the total push length corresponding to the previous level function of the current function and the value of the top register corresponding to the previous level function of the current function; wherein the total push length corresponding to the previous level function of the current function is determined according to the push length of each push instruction corresponding to the previous level function of the current function; wherein the previous level function of the current function is the function that has been most recently backtraced before the current function; Determine the value of the return register when running the previous level function of the current function according to the stack offset corresponding to the return register when running the previous level function of the current function, the value of the top register of the stack corresponding to the previous level function of the current function, and the total push length corresponding to the previous level function of the current function, and calculate the first address corresponding to the target stack frame of the current function according to the value of the return register when running the previous level function of the current function and the predetermined jump instruction length; The method further comprises: When it is determined that the first parsed instruction is not the push instruction, the second address is determined as a new reference address, and the step of determining the first legal instruction length according to the preset first instruction length detection algorithm is re-executed, and the step of shifting the first legal instruction length in the direction of the lower address based on the determined reference address to obtain the second address is performed, and the step of reading the first parsed instruction at the second address and determining whether the first parsed instruction is a push instruction is performed; And, the method further comprises: When it is determined that the first parsed instruction is the push instruction, and it is determined that the first parsed instruction does not trigger the return register to complete the push, the second address is determined as a new reference address, and the step of determining the first legal instruction length according to the preset first instruction length detection algorithm is re-executed, and the step of offsetting the first legal instruction length in the direction of the lower address based on the determined reference address to obtain the step corresponding to the second address is performed, and the step of reading the first parsed instruction at the second address and determining whether the first parsed instruction is a push instruction is performed; When the target stack frame is the first-level stack frame, determining the stack frame parameters corresponding to the target stack frame of the current function includes: Calling a backtrace function according to a preset stack backtrace start instruction, and judging whether the currently running target function is an exception handling function according to the backtrace function, wherein the backtrace function is a function for starting a stack backtrace process; When it is determined that the target function is the exception handling function, the determined exception stack is called to obtain the program running address corresponding to the exception information and the value corresponding to the stack top register as the stack frame parameter corresponding to the target stack frame of the current function; When it is determined that the target function is not the exception handling function, determining a designated task to be backtraced, and obtaining stack frame parameters corresponding to the designated task, determining the function where the stack frame parameters corresponding to the designated task are located as the current function, and determining the stack frame parameters corresponding to the designated task as stack frame parameters corresponding to the target stack frame of the current function; the designated task is a currently running task or a non-currently running task; Wherein, obtaining the stack frame parameters corresponding to the specified task includes: When the designated task is the currently running task, obtaining the program running address corresponding to the current CPU and the value corresponding to the stack top register according to the preset assembler as the stack frame parameters corresponding to the designated task; When the designated task is the non-currently running task, the program running address and the value of the stack top register are extracted from the context information corresponding to the designated task as stack frame parameters corresponding to the designated task.

2. The method for implementing variable-length instruction set system stack backtracing according to claim 1, characterized in that: The determining whether the first parsed instruction is a push instruction includes: Analyze the first parsing instruction to obtain an analysis result corresponding to the first parsing instruction, and determine whether the analysis result includes a predetermined feature code; When it is determined that the analysis result includes the feature code, determining that the first parsing instruction is a push instruction; When it is determined that the analysis result does not include the feature code, determining that the first parsed instruction is not a push instruction; Furthermore, after determining that the third address is equal to the jump address, and before determining the next level function of the current function as the new current function, the method further includes: Determine whether the jump address corresponding to the next level function of the current function is a preset task exit address; when it is determined that the jump address corresponding to the next level function of the current function is not the preset task exit address, determine that the jump address corresponding to the next level function of the current function stores a jump instruction for jumping from the next level function of the current function to the post-call function corresponding to the next level function of the current function, and trigger the execution of the operation of determining the next level function of the current function as the new current function; When it is determined that the jump address corresponding to the next level function is the preset task exit address, the stack backtracking interface is exited.

3. The method for implementing variable-length instruction set system stack backtracing according to claim 2, characterized in that: When it is determined that the first parsing instruction has triggered the completion of pushing the return register onto the stack, after determining the second address as the upper boundary of the current function corresponding to the target stack frame, the method further includes: Determine, according to the first parsing instruction, an instruction list corresponding to the first parsing instruction; Analyze the instruction list to obtain a first quantity corresponding to a first setting parameter and a second quantity corresponding to a second setting parameter in the instruction list, wherein the first setting parameter is a parameter in a preset bit state among all bits included in the instruction list, and the second setting parameter is a parameter in a preset bit position interval and in the preset bit state among all bits included in the instruction list; Determine a stack length corresponding to the first parsed instruction according to the first number and a preset register width; Determine a stack offset corresponding to the return register according to the second number and the preset register width; The value of the return register is determined according to the stack length, the stack offset and the determined value of the top register of the current function. The value of the return register is used to calculate the value of the program running address corresponding to the previous level function stack frame of the current function. The value of the program running address corresponding to the previous level function stack frame of the current function is used to determine the jump address corresponding to the next level function.

4. The method for implementing stack backtracing of a variable-length instruction set system according to any one of claims 1 to 3, characterized in that: The determining the first legal instruction length according to a preset first instruction length detection algorithm includes: According to a preset first instruction length detection algorithm, the first preset length is shifted toward the lower address direction based on the determined reference address to obtain a first pending instruction; Determine the running architecture type corresponding to the current stack backtrace, and determine the instruction set state according to the running architecture type, wherein the running architecture type corresponds to at least one instruction set state, and each instruction set state corresponds to at least one instruction length; According to the instruction lengths respectively corresponding to each of the instruction set states, determining whether the instruction length of the first pending instruction is one of the instruction lengths corresponding to all the instruction set states; When it is determined that the instruction length of the first pending instruction is not any instruction length corresponding to all the instruction set states, determining the second preset length as the first legal instruction length; When it is determined that the instruction length of the first pending instruction is one of the instruction lengths corresponding to all the instruction set states, the first preset length is determined to be a first legal instruction length.

5. A variable-length instruction set system stack backtracking implementation device, characterized in that: The device is used to execute the implementation method of variable-length instruction set system stack backtracing according to any one of claims 1 to 4, and the device includes: a determination module, configured to determine stack frame parameters corresponding to a target stack frame of a current function, wherein the stack frame parameters corresponding to the target stack frame include a first address corresponding to the target stack frame, wherein the first address is a program running address corresponding to the target stack frame, and the target stack frame is a first-level stack frame or a non-first-level stack frame; An addressing module, configured to determine a first legal instruction length according to a preset first instruction length detection algorithm, and to shift the first legal instruction length in a lower address direction based on a determined reference address to obtain a second address; the initially determined reference address is the first address; A push determination module, configured to read the first parsed instruction at the second address and determine whether the first parsed instruction is a push instruction; A first judgment module, configured to judge whether the first parsing instruction has triggered a return register to complete the stacking when the stacking judgment module judges that the first parsing instruction is the stacking instruction; The determination module is further configured to determine the second address as the upper boundary of the current function corresponding to the target stack frame when the first determination module determines that the first parsing instruction has triggered the return register to complete pushing; The addressing module is further used to determine the second legal instruction length according to a preset second instruction length detection algorithm, and to shift the second legal instruction length toward a higher address based on the second address to obtain a third address; The push determination module is further configured to read the second parsed instruction at the third address and determine whether the second parsed instruction is the push instruction; The first judgment module is further used to judge whether the third address is equal to the jump address corresponding to the current function when the push judgment module judges that the second parsing instruction is the push instruction, the jump address corresponding to the current function stores a jump instruction for jumping from the current function to a post-call function, and the post-call function is a function whose function calling sequence is after the function calling sequence of the current function; The determination module is also used to determine the next-level function of the current function as the new current function when the first judgment module determines that the third address is equal to the jump address, and trigger the execution of the operation of determining the stack frame parameters corresponding to the target stack frame of the current function.

6. A variable-length instruction set system stack backtracking implementation device, characterized in that: The device comprises: A memory storing executable program code; a processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the variable-length instruction set system stack backtracing implementation method as described in any one of claims 1-4.

7. A computer storage medium, characterized in that: The computer storage medium stores computer instructions, and when the computer instructions are called, they are used to execute the implementation method of variable-length instruction set system stack backtracing as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Method, device and system for determining function call relationship

    CN102109975A

  • Method and device for stack backtracking

    CN108984328A

  • Stack backtracking method and device

    CN113238883A

  • Call stack backtracking method and device of embedded system and computer equipment

    CN113742119A

  • Dynamic Identification of Stack Frames

    US20200371945A1