CN110007984B - Function call relation backtracking method and system based on Xtensa DSP - Google Patents

Function call relation backtracking method and system based on Xtensa DSP Download PDF

Info

Publication number
CN110007984B
CN110007984B CN201910260649.XA CN201910260649A CN110007984B CN 110007984 B CN110007984 B CN 110007984B CN 201910260649 A CN201910260649 A CN 201910260649A CN 110007984 B CN110007984 B CN 110007984B
Authority
CN
China
Prior art keywords
function
register
return address
current
backtracking
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910260649.XA
Other languages
Chinese (zh)
Other versions
CN110007984A (en
Inventor
宋成飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sipic Technology Co Ltd
Original Assignee
Sipic Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sipic Technology Co Ltd filed Critical Sipic Technology Co Ltd
Priority to CN201910260649.XA priority Critical patent/CN110007984B/en
Publication of CN110007984A publication Critical patent/CN110007984A/en
Application granted granted Critical
Publication of CN110007984B publication Critical patent/CN110007984B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • G06F9/4484Executing subprograms
    • G06F9/4486Formation of subprogram jump address

Abstract

The invention discloses a function call relation backtracking method and a system based on an Xtensa DSP, wherein the method comprises the following steps: registering an exception handling function in an exception vector table when the system is started; when an exception occurs in the function calling process, calling the exception handling function from the exception vector table to obtain a function return address; judging the validity of the function return address; and when the function return address is judged to be illegal, finishing function call relation backtracking. The invention registers the abnormal processing function in the abnormal vector table of the DSP, and when there is abnormal, the invention jumps to the abnormal processing function registered before. The exception handling function is responsible for reading current exception information and backtracking the call relation of the function, so that the problem can be quickly positioned.

Description

Function call relation backtracking method and system based on Xtensa DSP
Technical Field
The invention relates to the technical field of information, in particular to a function call relation backtracking method and system based on an Xtensa DSP.
Background
Function call relation backtracking is to perform reverse analysis on the basis of understanding how a processor organizes function calls. In the prior art, a function call backtracking mode is mainly based on mainstream general CPUs such as X86, ARM, and MIPS. These similar techniques cannot work with the DSP of the Xtensa architecture because the architecture of the processors is different. The reason is that: 1) the organization modes of the function call relations are different, and similar technologies store a function SP (StackPoint) and a function Return Address (RA) into a Stack space of a memory; 2) the function calling contract specifications are different; 3) different instructions exist, and each system has a set of instruction set, so the instruction analysis mode is different.
Generally, a service model borne by a DSP chip is simple, most of the models are simple calculation or control with a small amount of running code, and if no system exception is found during debugging in an IDE environment, it is not easy to cause a problem in actual use. The abnormal call stack backtracking technology needs to deeply understand the architecture of the chip, and a general chip user pays more attention to the realization of relevant parts of the service. The current conventional method of locating exceptions on a DSP is still implemented by the IDE tool and print log.
Disclosure of Invention
The invention registers the abnormal processing function in the abnormal vector table of the DSP, and when there is abnormal, the invention jumps to the abnormal processing function registered before. And the exception handling function is responsible for reading the current exception information and backtracking the call relation of the function. This allows for quick positioning.
The embodiment of the invention provides a function call relation backtracking method based on an Xtensa DSP, which is used for solving at least one of the technical problems.
In a first aspect, an embodiment of the present invention provides a Xtensa DSP-based function call relationship backtracking method, including:
s10, registering an exception handling function in the exception vector table when the system is started;
s20, when an exception occurs in the function calling process, calling the exception handling function from the exception vector table to obtain a function return address;
s30, judging the validity of the function return address;
and S40, when the function return address is judged to be illegal, finishing function call relation backtracking.
In a second aspect, an embodiment of the present invention provides a xtensia DSP-based function call relationship backtracking system, including:
the register program module is used for registering an exception handling function in the exception vector table when the system is started;
the information acquisition program module is used for calling the exception handling function from the exception vector table to obtain a function return address when an exception occurs in the function calling process;
the judging program module is used for judging the legality of the function return address;
and the backtracking ending program module is used for ending the backtracking of the function call relation when the function return address is judged to be illegal.
In a third aspect, an embodiment of the present invention provides a storage medium, where one or more programs including execution instructions are stored, where the execution instructions can be read and executed by an electronic device (including but not limited to a computer, a server, or a network device, etc.) to perform any of the xtensia DSP-based function call relationship trace methods described above in the present invention.
In a fourth aspect, an electronic device is provided, comprising: at least one processor, and a memory communicatively coupled to the at least one processor, wherein the memory stores instructions executable by the at least one processor, the instructions being executable by the at least one processor to enable the at least one processor to perform any of the xtensia DSP-based function call relationship trace back methods of the present invention as described above.
In a fifth aspect, an embodiment of the present invention further provides a computer program product, where the computer program product includes a computer program stored on a storage medium, and the computer program includes program instructions, when the program instructions are executed by a computer, the computer executes any one of the foregoing Xtensa DSP-based function call relation backtracking methods.
The embodiment of the invention has the beneficial effects that: the invention registers the abnormal processing function in the abnormal vector table of the DSP, and when there is an abnormality, the invention jumps to the previously registered abnormal processing function. The exception handling function is responsible for reading current exception information and backtracking the call relation of the function, so that the problem can be quickly positioned.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the description below are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
FIG. 1 is a flowchart of an embodiment of a Xtensa DSP-based function call relationship backtracking method of the present invention;
FIG. 2 is a flowchart of another embodiment of the Xtensa DSP-based function call relationship backtracking method of the present invention;
FIG. 3 is a flowchart of another embodiment of the Xtensa DSP-based function call relationship backtracking method of the present invention;
FIG. 4 is a flowchart of another embodiment of the Xtensa DSP-based function call relationship backtracking method of the present invention;
FIG. 5 is a diagram illustrating a register management mechanism in a windows rotation manner according to the present invention;
FIG. 6 is a diagram illustrating an embodiment of a function call in the present invention;
FIG. 7 is a schematic block diagram of another embodiment of the Xtensa DSP-based function-call relationship trace-back system of the present invention;
fig. 8 is a schematic structural diagram of an embodiment of an electronic device of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Furthermore, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising … …" does not exclude the presence of additional identical elements in the process, method, article, or apparatus that comprises the element.
At present, the conventional problem positioning means is realized by an IDE (integrated development environment) tool (Xplorer) provided by a DSP chip manufacturer, and the tool runs on a PC (personal computer) and can set breakpoints, trace a single step and query registers and a memory for a program. In addition, printf printing information is used in the code, and is a common positioning problem means.
It is desirable to be able to obtain which instruction is in question, what the type of error is, and by whom it was called when the exception occurred. The above technique cannot be satisfied.
In the embodiment of the invention, the exception handling function is registered in the exception vector table of the DSP, when an exception occurs, the exception handling function can jump to the exception handling function registered before, and the exception handling function is responsible for reading the current exception information and backtracking the call relation of the function, so that the problem can be quickly positioned.
As shown in fig. 1, a flowchart of an embodiment of a Xtensa DSP-based function call relationship backtracking method of the present invention includes:
s10, registering an exception handling function in the exception vector table when the system is started;
s20, when an exception occurs in the function calling process, calling the exception handling function from the exception vector table to obtain a function return address;
s30, judging the validity of the function return address;
and S40, when the function return address is judged to be illegal, ending the function call relation backtracking.
The invention registers the abnormal processing function in the abnormal vector table of the DSP, and when there is an abnormality, the invention jumps to the previously registered abnormal processing function. The exception handling function is responsible for reading current exception information and backtracking the call relation of the function, so that the problem can be quickly positioned. In addition, because the speed of positioning problems is increased, the stability of products is improved, and higher user satisfaction and recognition degree can be obtained.
As shown in fig. 2, in some embodiments, the determining the validity of the function return address includes:
s31, obtaining the address range of the code segment corresponding to the current function;
s32, judging whether the return address belongs to the code segment address range;
s33, if yes, judging that the function return value is legal;
and S34, if not, judging that the function return value is illegal.
There is a possibility in the system that the code segment is accidentally modified, so the currently obtained RA value is checked for validity. The code segment range is obtained by the starting address of the code segment and the starting address of the read-only data segment. Checking whether the RA address is in the range of the code segment, wherein the return address of the RA sub-function is positioned in the code segment; it is checked whether the addresses are aligned, e.g. a 32-bit processing RA should comply with a 4 byte alignment. If the RA value validity check fails. It is indicated that the current register has been destroyed skipping the round of backtracking.
As shown in fig. 3, in some embodiments, invoking the exception handling function from the exception vector table to obtain a function return address comprises:
s21, separating the logic register and the physical register by using a register management mechanism in a window rotation mode;
s22, configuring WINDOWSTART register and WINDOWBASE register to control window sliding to obtain function return address from the logic register.
In order to reduce performance overhead caused by frequent stack entering and stack exiting operations of a register, a DSP adopting an Xtensa architecture designs a register management mechanism in a windows rotation mode, a logic register (a0-a15) and a physical register (AR0-AR63) are separated, the logic register is switched through windows sliding during function calling, an independent register is distributed for each function, the stack pushing and stack exiting operations are reduced, and the performance is improved to a greater extent. In order to match with windows sliding, two special registers WINDOWSTART and WINDOWBASE are provided, and the windows sliding is controlled through the two registers, including function calling, sub-function returning, register covering and restoring and the like. The Windows ABI function Call convention is shown in Table 1, where a0 is used to store the return address, a1 is the sp stack pointer, a 2-a 7 are used to transfer the function entry, the stack is needed when the number of parameters exceeds 6, and a 8-a 15 are scratch registers, which may be used by subfunctions.
Callee Register Register Name Usage
0 a0 Saving return addresses of functions
1 a1 Current stack base address
2..7 a2...a7 Incorporation of functions
TABLE 1
As shown in fig. 4, in some embodiments, the Xtensa DSP-based function call relation backtracking method of the present invention further includes:
setting the first WINDOWBASE bit in the WINDOWSTART register as 0;
when the function return value is judged to be legal, checking whether a WINDOWSTART register and a WINDOWBASE register are simultaneously 0 or not;
if yes, ending the function call relation backtracking;
if not, translating the code segment of the function to which the function return address belongs;
judging whether stack underflow occurs to the current function according to the translated code segment;
if so, popping the register of the current function to restore the logical addresses a0-a3 in the register of the parent function, and jumping to step S20.
If not, updating the WINDOWBASE register, setting the corresponding bit in the WINDOWSTART register to 0, and jumping to the step S20.
In some embodiments, the determining whether stack underflow of the current function occurs according to the translated code segment includes:
starting from the function return address, 4 bytes are decreased each time to search for a call n instruction; wherein n can be 4, 8 or 12, the value of n indicates the number of registers occupied by the parent function, and in the format of the call instruction, bit 3-0 is a value with the identifier of 0101 fixed, and bit 5-4 represents n: 01 for n-1, 10 for n-8, 11 for n-1;
searching a command with bit 3-0 being 0101 in a code segment as a call command, then calculating bit 5-4 to obtain a value n, and calculating a WINDOWBASE value corresponding to a parent function after obtaining the value n:
WINDOWBASENEW=WINDOWBASECURRENT–x/4
checking WINDOWBASE in WINDOWSTART registerNEWWhether each bit is 0; if so, it is determined that the stack underflow occurs.
Firstly, an exception handling function is registered when a system is started, when an exception occurs, a state register for acquiring a current exception PC and an exception reason is provided, only the current error address is far insufficient to know, for example, the current exception PC points to a C library function such as memset, the problem often appears when the input parameter is an error address, and therefore, the user also needs to know who calls the function, and therefore, the call relations of the function need to be completely displayed in a recursive mode, namely the method for backtracking the call relations of the function based on the Xtensa DSP.
And step two, acquiring a function return value. As shown in fig. 5, in order to reduce performance overhead caused by frequent stack-in and stack-out operations of registers, the DSP adopting the xtensia architecture designs a register management mechanism in a windows rotation manner, which separates logical registers (a0-a15) from physical registers (AR 1-AR 31), and allocates independent registers to each function by windows sliding switching of the logical registers during function call, thereby reducing stack-pushing and stack-out operations and improving performance to a greater extent. In order to match with windows sliding, two special registers WINDOWSTART and WINDOWBASE are provided, and the sliding of windows is controlled through the two registers, including function calling, sub-function returning, register covering and restoring and the like. The Windows ABI function Call convention is shown in Table 1, where a0 is used to store the return address, a1 is the sp stack pointer, a 2-a 7 are used to transfer the function entry, the stack is needed when the number of parameters exceeds 6, and a 8-a 15 are scratch registers, which may be used by subfunctions.
The value registered in a0 is the Return Address (RA) of the current function. And meanwhile, setting the WINDOWBASE bits in WINDOWSTART to 0.
Step three: and judging whether the RA value is legal or not. There is a possibility that a code segment is accidentally modified in the system, and therefore the currently acquired RA value is subjected to a validity check. The code segment range is obtained by the starting address of the code segment and the starting address of the read-only data segment. Checking whether the RA address is in the range of the code segment, wherein the RA is the return address of the sub-function and is positioned in the code segment; it is checked whether the addresses are aligned, e.g. a 32-bit processing RA would fit 4-byte alignment. If the RA value does not pass the validity check, the current register is destroyed and the backtracking is skipped.
Step four: and judging whether the WINDOWSTART of the register is equal to 0 and the WINDOWBASE is equal to 1, if yes, indicating that no function exists in the windows register and the circulation can be skipped, and if not, continuing to perform backtrack processing.
Step five: the code instructions of the functions to which the RA belongs are translated, and the callx instruction is searched by decrementing 4 bytes each time from the address of the RA, wherein x can be 4, 8 and 12, namely, call4, call8 and call12, and the value of x indicates the number of registers occupied by the parent function. After the value of x is obtained, the WINDOWBASE value corresponding to the parent function can be calculated:
WINDOWBASENEW=WINDOWBASECURRENT–x/4。
step six: checking WINDOWBASE IN WINDOWSTARTNEWAnd if the bit is 0, the register of the parent function is covered, the original register is stored in the stack of the child function, register popping is needed, and the step seven is executed. And if the number is 1, skipping to the step two, and carrying out a new round of analysis.
Step seven: when the windows register slides, if the register in the window body is already occupied by other functions, the register in the current window body can be saved in the stack of the subfunction. For example, the invocation relationship A->B->C->D-E, E will cover A when the frame slides, as shown in FIG. 6, at this time the register a0-a3 for the A function will be saved in the stack of the sub-function B function, ranging from SP-16 to SP-4. When tracing back to the A function, the first WINDOWBASE in WINDOWSTART will be foundNEWOne bit is 0 because the bit corresponding to WINDOWSTART has been set to zero at the time of tracing back the E function.
Firstly, the stack address of the current function (subfunction) is saved and at the same time WINDOWBASE is usedNEWUpdating to WINDOWBASE register, sliding the window register to the position of the parent function, and obtaining the access authority of the parent function register. And then, popping the register value stored in the subfunction stack, recovering the register value to a0-a3, and jumping to the step one by setting the position 1 corresponding to WINDOWSTART.
As shown in fig. 7, an embodiment of the present invention further provides a xtensia DSP-based function call relationship backtracking system 700, including:
a registration program module 710 for registering an exception handling function in the exception vector table at system startup;
an information obtaining program module 720, configured to, when an exception occurs during a function call, call the exception handling function from the exception vector table to obtain a function return address;
a determining program module 730, configured to determine validity of the function return address;
a backtracking ending program module 740, configured to end function call relation backtracking when it is determined that the function return address is illegal.
It should be noted that for simplicity of explanation, the foregoing method embodiments are described as a series of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated ordering of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention. In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to the related descriptions of other embodiments.
In some embodiments, the present invention provides a non-transitory computer readable storage medium, in which one or more programs including execution instructions are stored, and the execution instructions can be read and executed by an electronic device (including but not limited to a computer, a server, or a network device, etc.) to perform any of the xtensia DSP-based function call relationship backtracking methods described above in the present invention.
In some embodiments, the present invention further provides a computer program product, which includes a computer program stored on a non-volatile computer-readable storage medium, where the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes any one of the above methods for xtensia DSP-based function call relationship backtracking.
In some embodiments, an embodiment of the present invention further provides an electronic device, which includes: at least one processor, and a memory communicatively coupled to the at least one processor, wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform an xtensia DSP-based function call relationship trace back method.
In some embodiments, an embodiment of the present invention further provides a storage medium, on which a computer program is stored, where the program is executed by a processor, and is based on a function call relationship backtracking method of Xtensa DSP.
The Xtensa DSP-based function call relationship backtracking system according to the embodiment of the present invention may be used to execute the Xtensa DSP-based function call relationship backtracking method according to the embodiment of the present invention, and accordingly achieve the technical effect achieved by the Xtensa DSP-based function call relationship backtracking method according to the embodiment of the present invention, which is not described herein again. In the embodiment of the present invention, the relevant functional module may be implemented by a hardware processor (hardware processor).
Referring now to FIG. 8, shown is a block diagram of a computer system 800 suitable for use in implementing an electronic device of an embodiment of the present invention. The electronic device shown in fig. 8 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 8, the computer system 800 includes a Central Processing Unit (CPU)801 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)802 or a program loaded from a storage section 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data necessary for the operation of the system 800 are also stored. The CPU 801, ROM 802, and RAM 803 are connected to each other via a bus 804. An input/output (I/O) interface 805 is also connected to bus 804.
The following components are connected to the I/O interface 805: an input portion 806 including a keyboard, a mouse, and the like; an output section 807 including a signal such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 808 including a hard disk and the like; and a communication section 809 including a network interface card such as a LAN card, a modem, or the like. The communication section 809 performs communication processing via a network such as the internet. A drive 810 is also connected to the I/O interface 805 as needed. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 810 as necessary, so that a computer program read out therefrom is mounted on the storage section 808 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 809 and/or installed from the removable medium 811. The computer program executes the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 801.
The product can execute the method provided by the embodiment of the application, and has the corresponding functional modules and beneficial effects of the execution method. For technical details that are not described in detail in this embodiment, reference may be made to the methods provided in the embodiments of the present application.
The electronic device of the embodiments of the present application exists in various forms, including but not limited to:
(1) mobile communication devices, which are characterized by mobile communication functions and are primarily targeted at providing voice and data communications. Such terminals include smart phones (e.g., iphones), multimedia phones, functional phones, and low-end phones, among others.
(2) The ultra-mobile personal computer equipment belongs to the category of personal computers, has calculation and processing functions and generally has the characteristic of mobile internet access. Such terminals include PDA, MID, and UMPC devices, such as ipads.
(3) Portable entertainment devices such devices may display and play multimedia content. Such devices include audio and video players (e.g., ipods), handheld game consoles, electronic books, as well as smart toys and portable car navigation devices.
(4) The server is similar to a general computer architecture, but has higher requirements on processing capacity, stability, reliability, safety, expandability, manageability and the like because of the need of providing high-reliability service.
(5) And other electronic devices with data interaction functions.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a general hardware platform, and certainly can also be implemented by hardware. Based on such understanding, the above technical solutions substantially or contributing to the related art may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (8)

1. A function call relation backtracking method based on an Xtensa DSP comprises the following steps:
s10, registering an exception handling function in the exception vector table when the system is started;
s20, when an exception occurs in the current function calling process, calling the exception handling function from the exception vector table to obtain the function return address of the current function, where the calling process includes: a window rotation mode register management mechanism is adopted to separate a logic register from a physical register and configure a WINDOWSTART register and a WINDOWBASE register so as to control the sliding of a window to obtain a function return address of the current function from the logic register;
s30, judging the validity of the function return address of the current function, including: acquiring a code segment address range corresponding to the current function, judging whether a function return address of the current function belongs to the code segment address range, if so, judging that the function return address of the current function is legal, and if not, judging that the function return address of the current function is illegal;
and S40, when the function return address of the current function is judged to be illegal, ending the function call relation backtracking.
2. The method of claim 1, further comprising:
setting a first WINDOWBASE bit in the WINDOWSTART register to be 0;
when judging that the function return address of the current function is legal, checking whether a WINDOWSTART register and a WINDOWBASE register are 0 at the same time;
if yes, ending the function call relation backtracking;
if not, continuing the function call relation backtracking.
3. The method of claim 2, wherein the continuing the function call relationship backtracking comprises:
translating the code segment of the current function to which the function return address of the current function belongs;
judging whether the current function generates stack underflow according to the translated code segment;
if so, popping the register of the current function to restore the logical addresses a0-a3 in the register of the parent function, and jumping to the step S20.
4. The method of claim 3, wherein the determining whether stack underflow occurs for the current function according to the translated code segment comprises:
starting from the function return address of the current function, decreasing by 4 bytes each time to find a call n instruction; wherein n is 4, 8 or 12, the value of n indicates the number of registers occupied by the parent function, in the format of call instruction, bits 3-0 are marked as 0101, and bits 5-4 represent the value of n: 01 for n =1, 10 for n =8, 11 for n = 1;
searching a call instruction with bit 3-0 being 0101 in a code segment, then calculating bit 5-4 to obtain the value of n, and calculating the WINDOWBASE value corresponding to the parent function after obtaining the value of n:
WINDOWBASENEW = WINDOWBASECURRENT –x/4
checking the WINDOWBASE number in the WINDOWSTART registerNEWWhether each bit is 0;
if so, determining that stack underflow occurs for the current function.
5. The method of claim 4, further comprising:
when checking the WINDOWBASE in the WINDOWSTART registerNEWWhen each bit is 1, updating the WINDOWBASE register, and updating the corresponding WINDOWBASE in the WINDOWSTART registerNEWThe individual bits are set to 0, and it jumps to step S20.
6. A Xtensa DSP-based function call relationship backtracking system, comprising:
the register program module is used for registering an exception handling function in the exception vector table when the system is started;
an information obtaining program module, configured to, when an exception occurs in a current function calling process, call the exception handling function from the exception vector table to obtain a function return address of the current function, where the calling process includes: a window rotation mode register management mechanism is adopted to separate a logic register from a physical register and configure a WINDOWSTART register and a WINDOWBASE register so as to control the sliding of a window to obtain a function return address of the current function from the logic register;
the judging program module is used for judging the validity of the function return address of the current function, and comprises the following steps: acquiring a code segment address range corresponding to the current function, judging whether a function return address of the current function belongs to the code segment address range, if so, judging that the function return address of the current function is legal, and if not, judging that the function return address of the current function is illegal;
and the backtracking ending program module is used for ending the backtracking of the function call relation when judging that the function return address of the current function is illegal.
7. An electronic device, comprising: at least one processor, and a memory communicatively coupled to the at least one processor, wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the steps of the method of any one of claims 1-5.
8. A storage medium on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 5.
CN201910260649.XA 2019-04-02 2019-04-02 Function call relation backtracking method and system based on Xtensa DSP Active CN110007984B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910260649.XA CN110007984B (en) 2019-04-02 2019-04-02 Function call relation backtracking method and system based on Xtensa DSP

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910260649.XA CN110007984B (en) 2019-04-02 2019-04-02 Function call relation backtracking method and system based on Xtensa DSP

Publications (2)

Publication Number Publication Date
CN110007984A CN110007984A (en) 2019-07-12
CN110007984B true CN110007984B (en) 2022-07-15

Family

ID=67169607

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910260649.XA Active CN110007984B (en) 2019-04-02 2019-04-02 Function call relation backtracking method and system based on Xtensa DSP

Country Status (1)

Country Link
CN (1) CN110007984B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114416219B (en) * 2021-12-31 2023-05-23 北京五八信息技术有限公司 System function calling method, device, electronic equipment and readable medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101122881A (en) * 2007-09-20 2008-02-13 福建星网锐捷网络有限公司 CPU abnormal point positioning diagnosis method based MIPS structure
CN101539883A (en) * 2009-05-05 2009-09-23 北京和利时系统工程有限公司 Error tracking method of embedded system and device thereof
US20190044971A1 (en) * 2018-06-29 2019-02-07 Vadim Sukhomlinov Techniques to provide function-level isolation with capability-based security

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101122881A (en) * 2007-09-20 2008-02-13 福建星网锐捷网络有限公司 CPU abnormal point positioning diagnosis method based MIPS structure
CN101539883A (en) * 2009-05-05 2009-09-23 北京和利时系统工程有限公司 Error tracking method of embedded system and device thereof
US20190044971A1 (en) * 2018-06-29 2019-02-07 Vadim Sukhomlinov Techniques to provide function-level isolation with capability-based security

Also Published As

Publication number Publication date
CN110007984A (en) 2019-07-12

Similar Documents

Publication Publication Date Title
CN108776587B (en) Data acquisition method and device, computer equipment and storage medium
US10802939B2 (en) Method for scanning cache of application and electronic device
CN108959199A (en) A kind of log highlights method, apparatus, storage medium and android terminal
WO2023155940A1 (en) Mini program compiling method and apparatus, mini program running method and apparatus, and storage medium
CN114676040A (en) Test coverage verification method and device and storage medium
CN110007984B (en) Function call relation backtracking method and system based on Xtensa DSP
CN110955409A (en) Method and device for creating resources on cloud platform
CN110652728A (en) Game resource management method and device, electronic equipment and storage medium
CN114003421B (en) Virtual machine timeout mechanism testing method, system, terminal and storage medium
CN112069052A (en) Abnormal object detection method, device, equipment and storage medium
CN108875363B (en) Method and device for accelerating virtual execution, electronic equipment and storage medium
CN114356290A (en) Data processing method and device and computer readable storage medium
CN110688582B (en) Application recommendation method, application recommendation device and terminal equipment
CN112256252B (en) Interface generation method and device, storage medium and electronic equipment
CN113742156A (en) Joint debugging method and device, electronic equipment and storage medium
CN117407430B (en) Data query method, device, computer equipment and storage medium
CN111949510B (en) Test processing method, device, electronic equipment and readable storage medium
CN112860224B (en) Function execution environment construction method and device, electronic equipment and storage medium
CN113094379B (en) Anchored user data maintenance method, device, equipment and medium
WO2017028729A1 (en) Method, apparatus, and electronic device for determining whether an application program is an authorized application program
CN111209056B (en) Method and device for loading function, readable storage medium and electronic equipment
US20230376880A1 (en) Method and system for user performance evaluation
CN115858985A (en) Method for establishing multi-language environment and switching languages on same website
CN117873646A (en) Firmware simulation method and system based on peripheral access point guidance
CN112199224A (en) Analysis method and device of crash file, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 215123 building 14, Tengfei Innovation Park, 388 Xinping street, Suzhou Industrial Park, Suzhou City, Jiangsu Province

Applicant after: Sipic Technology Co.,Ltd.

Address before: 215123 building 14, Tengfei Innovation Park, 388 Xinping street, Suzhou Industrial Park, Suzhou City, Jiangsu Province

Applicant before: AI SPEECH Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant