Chip software debugging method and device based on task stack backtracking mechanism
Through the chip software debugging method based on the task stack traceback mechanism, using disassembly maximum matching processing and stack traceback analysis, the problem of real-time monitoring and debugging of the chip when the J-Tag debugger cannot be connected is solved, rapid diagnosis and positioning are achieved, and the efficiency is improved Chip debugging efficiency.
Patent Information
- Application Number
- CN202410787526.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2024-08-27
AI Technical Summary
When the J-Tag debugger cannot be connected, there is a lack of real-time monitoring and debugging methods for the chip, making it difficult to effectively diagnose and locate the chip's anomalies during the development process.
The chip software debugging method and device based on the task stack traceback mechanism is used to judge the data integrity by receiving the stack data and log files uploaded by the chip, perform disassembly maximum matching processing, trace back the function call trace, and locate the location of the exception.
It achieves rapid diagnosis and location of chip anomalies, improves chip debugging efficiency, and provides real-time monitoring and debugging capabilities when the J-Tag interface cannot be used.
Smart Images

Figure CN118550834A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of chip debugging technology, and in particular to a chip software debugging method and device based on a task stack backtracing mechanism. Background Art
[0002] During the chip development process, a hardware debugging module with a J-Tag interface is usually used to perform boundary scanning on the chip to obtain chip operation information. However, when a J-Tag debugger cannot be connected, there is a lack of real-time monitoring and debugging methods for the chip. Summary of the invention
[0003] The present invention provides a chip software debugging method and device based on a task stack backtracing mechanism.
[0004] According to a first aspect of the present disclosure, a chip software debugging method based on a task stack backtracking mechanism is provided, which is applied to a host computer. The method comprises:
[0005] Receive stack data and log files uploaded by the chip;
[0006] Determining whether the stack data is complete stack data according to the log file;
[0007] If so, the complete stack data is disassembled for maximum matching to obtain a backtrace of function call traces, so that the staff can locate the location of the exception according to the function call traces.
[0008] According to the above aspects and any possible implementation manner, an implementation manner is further provided, wherein the method further includes:
[0009] If not, the stack data is temporarily stored, and a search is performed to determine whether a preset end mark appears in the stack data;
[0010] If the end mark appears, the temporarily stored stack data is used as complete stack data.
[0011] According to the above aspects and any possible implementation, an implementation is further provided.
[0012] The stack data is generated by the following steps:
[0013] The chip records the stack bottom pointer when the task is created, and the stack top pointer during the task execution, and uses the data in the address space pointed to by the stack bottom pointer and the stack top pointer as stack data. According to the above aspects and any possible implementation method, a further implementation method is provided.
[0014] The stack data can also be generated by the following steps:
[0015] When the chip detects an abnormal call, it locates the function according to the pre-written stack backtrace, and backtraces the function call track information recorded in the corresponding task stack as "stack frame" data.
[0016] According to the above aspects and any possible implementation, an implementation is further provided.
[0017] The entire stack data includes complete stack data or "stack frame" data corresponding to multiple tasks;
[0018] The disassembling of all stack data for maximum matching to obtain a backtraced function call trace includes:
[0019] Go through the stack data of each task one by one, and match the instruction address in the stack data with the instruction address in the preset disassembly file;
[0020] The function name and instruction address corresponding to the successfully matched stack data are saved as a node of the function call trace to obtain the backtraced function call trace.
[0021] According to the above aspects and any possible implementation, an implementation is further provided, wherein the function name and instruction address corresponding to the successfully matched stack data are saved as a node of the function call trace, including:
[0022] Search the disassembly file for the most recent valid instruction that corresponds to the stack data that matches successfully;
[0023] If the instruction can generate a stack push operation, continue searching forward until the function name in the function header is found;
[0024] The searched function names and corresponding instruction addresses are saved one by one as nodes of the function call trace in the search order.
[0025] According to the above aspects and any possible implementation manner, an implementation manner is further provided, wherein the method further includes:
[0026] Delete nodes with duplicate function names.
[0027] According to a second aspect of the present disclosure, a chip software debugging device based on a task stack backtracking mechanism is provided, which is applied to a host computer. The device includes:
[0028] Data receiving module, used to receive stack data and log files uploaded by the chip;
[0029] A determination module, used for determining whether the stack data is complete stack data or "stack frame" data according to the log file;
[0030] The stack backtrace module is used to, if so, perform a disassembly maximum matching process on all the stack data to obtain a backtrace function call trace, so that the staff can locate the occurrence position of the exception according to the function call trace.
[0031] According to a third aspect of the present disclosure, an electronic device is provided, which includes a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the program, the method described above is implemented.
[0032] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the method according to the first aspect of the present disclosure is implemented.
[0033] The chip software debugging method and device based on the task stack backtracing mechanism provided by the embodiments of the present disclosure can quickly diagnose and locate chip anomalies through a series of stack piling, stack backtracing analysis, and host computer real-time monitoring software tools and other technologies, thereby greatly improving chip debugging efficiency.
[0034] It should be understood that the contents described in the summary of the invention are not intended to limit the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, among which:
[0036] Figure 1 A flowchart of a chip software debugging method based on a task stack backtracing mechanism according to an embodiment of the present disclosure is shown;
[0037] Figure 2 A block diagram of a chip software debugging device based on a task stack backtracing mechanism according to an embodiment of the present disclosure is shown;
[0038] Figure 3 A schematic block diagram of an exemplary electronic device capable of implementing an embodiment of the present disclosure is shown;
[0039] Figure 4 A schematic diagram of function call stacking according to an embodiment of the present disclosure is shown;
[0040] Figure 5 A schematic diagram of a stack space function call chain according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0042] In addition, the term "and / or" in this article is only a description of the association relationship between the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0043] The present disclosure provides a technical means for real-time monitoring of chip operation and diagnosis of abnormalities. By utilizing the computing power and chart drawing ability of the host computer, the chip operation status, operation trajectory, abnormal point location, chart display, statistical calculation and other functions can be monitored in real time, which greatly enriches the chip debugging means and greatly improves the chip debugging efficiency.
[0044] Figure 1 The flowchart of a chip software debugging method 100 based on a task stack backtracking mechanism according to an embodiment of the present disclosure is shown. The method 100 includes:
[0045] Step 110: receiving a log file uploaded by the chip, which may contain stack data.
[0046] In some embodiments, the stack data is generated by the following steps: the chip records the stack bottom pointer when the task is created, and the stack top pointer during the task execution, and uses the data in the address space pointed to by the stack bottom pointer and the stack top pointer as the stack data. The stack data can also be generated by the following steps: when the chip detects an abnormal call, according to the pre-written stack backtrace positioning function, the function call trace information recorded in the corresponding task stack is backtracked as the stack frame data.
[0047] In some embodiments, the chip instruction set implements atomic operations. When a function call occurs (for example, Figure 4 In the function B calls function C), the stack address corresponding to the return instruction of the current function is pushed onto the stack, and then the return instruction address of the called function is pushed onto the stack, such as Figure 4The diagram of function call stacking is shown. When the called function ends, the corresponding atomic operation is implemented to pop the above two addresses in reverse order. In view of this atomic operation, the stack address corresponding to the return address of the currently running function needs to be stored in a general register Rx, and when a function call occurs, the data in Rx is pushed onto the stack. The stack push and pop instructions can be compiled with the compiler compilation options to attach the first instruction to each C language function, so that the chain of function call sequence can be recorded in the stack space. When a function call occurs, the stack push operation is performed in the manner described above, and the function call trace link data will be stored in the stack space, such as Figure 5 The diagram shows the stack space storing function call chain data. The return address of the function is stored in a certain position in the stack space. The data pushed into the stack last time at this position is the stack space address where the return address of the upper function is located. And so on, a function call track link is formed. Finding any node on the link can push the function call track of the entire task forward or backward.
[0048] In some embodiments, the task stack is piled, and the chip implements atomic operations of push and pop instructions. When a function call occurs, the stack space address corresponding to the return address of the function currently executed by the chip and the return address of the called function can be pushed and popped in sequence. When the chip's machine instructions implement a function call, the stack space address where its own return address is located is pushed into the stack first, and then the return address of the function to be called is pushed into the stack, forming a stack information address chain of the function call relationship. The compiler compiles the chip stack backtrace machine instruction and attaches it to each C language function as the first instruction executed by the C language function, and can control whether the stack backtrace function is compiled into the binary image file through compilation options.
[0049] In some embodiments, the stack data is exported to the host computer in real time or at an appropriate time through a specific method, such as a serial port (USART). The host computer analysis software is used to perform backtrace analysis on the stack data to find the C language function call trace, locate abnormal problems, etc. In one case, the chip intermittently outputs the data in each task stack to the host computer through peripherals such as the serial port (USART). The chip program only needs to record the bottom pointer of the stack and the real-time top pointer when the task is created, and output the data between the two addresses, and the host computer can receive and analyze it in real time. In another case, when an exception occurs and is detected, a pre-written stack backtrace positioning function can be used, that is, a pile driving function in the task stack, which is called when an exception occurs, such as when a stack overflow, memory allocation failure, assertion error, etc. occurs. The stack backtrace positioning function is as shown in the attached Figure 4 The first statement of function C in the above example is to declare a local variable, such as assigning a value of 0x5a5a5a5a to anchor the first address of the function on the stack. The address of the variable is obtained by using the C language address symbol '&'. This address is the first address of the function on the stack. Figure 4The return address of function C is 0x2100200, which is the address where function B is stored in the stack. In this way, function B can be located as the starting point (first address) of the function call relationship. If the stack grows toward the lower address, the address plus 4 is the return address of the function itself, and the address plus 4 is the stack address where the return address of the upper function is stored. The return address of the function itself and the stack address where the return address of the upper function is stored are collectively called "stack frame" data, as shown in the figure. Figure 4 As shown, the starting point of the call link is found, and by analogy, the function call trace information recorded in the task stack can be output to the host computer.
[0050] In some embodiments, stack data is exported to the host computer and stored in text format. Because each serial port (USART) tool receives text in a different encoding format, the stack backtrace analysis tool first opens the file in binary mode, reads the file header, obtains the encoding format standard, and then reads all data in the corresponding format standard.
[0051] Step 120: determine whether the stack data is complete stack data or “stack frame” data according to the log file.
[0052] In some embodiments, the chip outputs chip information from the serial port (USART) in real time, and may output stack data intermittently or output stack data when encountering an exception, so the log file needs to be monitored in real time. If the log file already contains the end mark of the stack data (for example, a pre-set end mark), it is considered to be complete stack data or "stack frame" data.
[0053] Step 130: If yes, then the complete stack data or the "stack frame" data is subjected to disassembly maximum matching processing to obtain a backtrace function call trace.
[0054] This allows staff to locate the location of the abnormality based on the function call trace.
[0055] In some embodiments, the entire stack data includes stack data corresponding to multiple tasks; the disassembly maximum matching process is performed on the entire stack data to obtain a backtraced function call trace, including: traversing the stack data of each task one by one, matching the instruction address in the stack data with the instruction address in a preset disassembly file; saving the function name and instruction address corresponding to the stack data that successfully matches the disassembly file as a node of the function call trace, to obtain a backtraced function call trace. The disassembly file will indicate the address of each assembly instruction.
[0056] In some embodiments, if the serial port outputs "stack frame" data, the host computer traces back the positioning function according to the pre-written chip-side stack as described above, obtains the reverse starting point of the function call relationship (the first address of the backtracking), performs backtracking matching according to the method described in step 110, and executes the operation of finding the function call link to obtain the function call link data. However, due to the complexity of the function call relationship, compilation optimization, and the different selection of the starting point of the function call link, it is impossible to reflect the execution process of the entire task and the resulting behavioral consequences through only one link. Therefore, the task stack data can be traversed one by one by disassembling the maximum matching method of the full stack data, and matched with the instruction address in the disassembled file. If the match is successful, the function name is saved, and the repeated function name is removed, that is, only the C language function name that is successfully matched for the first time is recorded, so as to realize the maximum possible tracing of the C language function call track using the stack data, and help developers locate problems and understand the running process of the task.
[0057] In some embodiments, the function name and instruction address corresponding to the stack data that successfully matches the disassembly file are saved as a node of the function call trace, including: searching the disassembly file for the most recent valid instruction corresponding to the stack data that successfully matches the disassembly file; if the instruction can generate a push operation, continue searching forward until the function name information in the function header is found; and save the searched function names and corresponding instruction addresses one by one as a node of the function call trace in the search order.
[0058] Specifically, the host computer uses Python and other languages to parse the stack data, which mainly involves regular expression matching, matching the stack data with the instruction address in the disassembly file. After the match is successful, the nearest valid instruction is searched forward. If the instruction can generate a stack push operation, the match is successful, and the forward search is continued to find the function header (the function header refers to the starting position of a function in the disassembly, which is identified by a keyword, such as .GLOBAL, __FUNCTION__, etc.), and the function name is obtained to determine the C language function of the program running trajectory. The above-mentioned "last valid instruction" refers to instructions other than empty instructions (such as nop instructions, placeholder instructions, etc.), and "instructions that can generate stack push operations" refer to branch instructions (br), call instructions (call), etc. If the stack data is the first address of a function, it is also considered a valid match, because when the function is called, the first address will also be pushed into the stack, and it is also a valid program running trajectory node.
[0059] In some embodiments, first, tasks are executed sequentially and can be interrupted by hard or soft interrupts, or by high-priority tasks that preempt the CPU execution, but they are generally executed sequentially, so there is only one function call chain. During task execution, stack in and out operations are frequently performed, so if you trace back at a certain point in time, you may not be able to trace back the entire function call chain of the task. Secondly, the compiler will also perform optimizations, resulting in differences between the call relationship represented by the data in the stack space and the call relationship displayed by the code. For example, Figure 4 and Figure 5 As shown, it can be called the "stack frame" method. This method can accurately trace the function call relationship, but the link that can be traced is short. After many functions are called and executed, the "stack frame" data is popped out of the stack, so it cannot be traced. Therefore, the present disclosure has also made a "maximum matching method", which is to match the data in the stack with the address in the disassembly file one by one. According to the maximum matching principle described above, if a match is found, the function name and address are recorded as a node in the function call link. This will trace back to a longer function call link, but the disadvantage is that the accuracy is not high. Because of compiler optimization, data may be shared in the stack space, etc., some uncalled functions also appear in the link, or there are multiple identical nodes in the link, that is, a certain function is repeatedly called. In this case, only the first occurrence position is recorded, that is, de-duplication processing.
[0060] In some embodiments, the method further includes: if not, temporarily storing the stack data, and finding whether a preset end mark appears in the stack data; if the end mark appears, the temporarily stored stack data is used as the complete stack data. Specifically, since the chip outputs stack data intermittently, or outputs stack data when encountering an exception, it is necessary to monitor the log file in real time. Therefore, it is necessary to read incremental data at preset time intervals. For example, the log file is incrementally read every 1 second. If stack data is found, the stack data is stored in a python data frame for temporary storage, and the file is continued to be read to find the end mark of the stack data. After the remaining stack data is appended to the data frame, the stack data is subjected to the stack backtracing analysis operation described above, and then the log data is continued to be incrementally read. Repeated cycles can obtain the function call sequence and operation trajectory of all operating system tasks.
[0061] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present disclosure is not limited by the order of the actions described, because according to the present disclosure, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present disclosure.
[0062] The above is an introduction to the method embodiment. The following is a further explanation of the scheme disclosed in the present invention through an apparatus embodiment.
[0063] Figure 2 FIG. 2 shows a block diagram of a chip software debugging device 200 based on a task stack backtracking mechanism according to an embodiment of the present disclosure. Figure 2 As shown, the device 200 includes:
[0064] The data receiving module 210 is used to receive the log file uploaded by the chip, which may contain stack data;
[0065] A determination module 220, configured to determine whether the stack data is complete stack data or "stack frame" data according to the log file;
[0066] The stack backtrace module 230 is used to, if yes, perform a disassembly maximum matching process on all the stack data to obtain a backtrace function call trace, so that the staff can locate the location where the exception occurs according to the function call trace.
[0067] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the described module can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0068] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0069] Figure 3 A schematic block diagram of an electronic device 300 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0070] The electronic device 300 includes a computing unit 301, which can perform various appropriate actions and processes according to a computer program stored in a ROM 302 or a computer program loaded from a storage unit 308 into a RAM 303. In the RAM 303, various programs and data required for the operation of the electronic device 300 can also be stored. The computing unit 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An I / O interface 305 is also connected to the bus 304.
[0071] A number of components in the electronic device 300 are connected to the I / O interface 305, including: an input unit 306, such as a keyboard, a mouse, etc.; an output unit 307, such as various types of displays, speakers, etc.; a storage unit 308, such as a disk, an optical disk, etc.; and a communication unit 309, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 309 allows the electronic device 300 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0072] The computing unit 301 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 301 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 301 performs the various methods and processes described above, such as method 100. For example, in some embodiments, the method 100 may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 308. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 300 via the ROM 302 and / or the communication unit 309. When the computer program is loaded into the RAM 303 and executed by the computing unit 301, one or more steps of the method 100 described above may be performed. Alternatively, in other embodiments, the computing unit 301 may be configured to perform the method 100 in any other appropriate manner (e.g., by means of firmware).
[0073] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0074] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0075] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0076] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0077] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0078] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0079] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0080] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A chip software debugging method based on task stack backtracking mechanism, applied to the host computer, It is characterized in that include: Receive stack data and log files uploaded by the chip; Determining whether the stack data is complete stack data according to the log file; If so, the complete stack data is disassembled for maximum matching to obtain a backtracked function call trace, so that the staff can locate the location where the exception occurs based on the function call trace.
2. The method according to claim 1, It is characterized in that The method further comprises: If not, the stack data is temporarily stored, and a search is performed to determine whether a preset end mark appears in the stack data; If the end mark appears, the temporarily stored stack data is used as complete stack data.
3. The method according to claim 1, It is characterized in that The stack data is generated by the following steps: The chip records the stack bottom pointer when the task is created and the stack top pointer during the task execution, and uses the data in the address space pointed to by the stack bottom pointer and the stack top pointer as stack data.
4. The method according to claim 1, It is characterized in that The stack data can also be generated by the following steps: When the chip detects an abnormal call, it locates the function according to the pre-written stack backtrace, and backtraces the function call track information recorded in the corresponding task stack as "stack frame" data.
5. The method according to claim 1, It is characterized in that The entire stack data includes complete stack data or "stack frame" data corresponding to multiple tasks; The disassembling of all stack data for maximum matching to obtain a backtraced function call trace includes: Go through the stack data of each task one by one, and match the instruction address in the stack data with the instruction address in the preset disassembly file; The function name and instruction address corresponding to the successfully matched stack data are saved as a node of the function call trace to obtain the backtraced function call trace.
6. The method according to claim 5, It is characterized in that The method of saving the function name and instruction address corresponding to the successfully matched stack data as a node of the function call trace includes: Search the disassembly file for the most recent valid instruction that corresponds to the stack data that matches successfully; If the instruction can generate a stack push operation, continue searching forward until the function name in the function header is found; The searched function names and corresponding instruction addresses are saved one by one as nodes of the function call trace in the search order.
7. The method according to claim 5 or 6, It is characterized in that The method further comprises: Delete the nodes with duplicate function names.
8. A chip software debugging device based on task stack backtracking mechanism, applied to a host computer, It is characterized in that include: Data receiving module, used to receive stack data and log files uploaded by the chip; A determination module, used for determining whether the stack data is complete stack data or "stack frame" data according to the log file; The stack backtrace module is used to, if so, perform a disassembly maximum matching process on all the stack data to obtain a backtrace function call trace, so that the staff can locate the occurrence position of the exception according to the function call trace.
9. An electronic device, It is characterized in that include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, It is characterized in that The computer instructions are used to cause the computer to execute the method according to any one of claims 1-7.
Citation Information
Cited By
Fault tracing method and device for service system assertion failure event
CN120743607A
