Method and device for obtaining stack information of thread crash
By adding a nor-flash driver to the microkernel, the thread crash stack information is written to nor-flash, and is read and recorded to the log file by the user space crash processing thread, which solves the problem that the PLC controller software cannot obtain the thread crash stack. Information issues enable effective transmission and recording of information.
Patent Information
- Application Number
- CN202111612874.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-27
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2041-12-27
AI Technical Summary
The PLC controller software runs in user space and cannot access the memory of the microkernel, resulting in the thread crashing stack information that cannot be obtained when the thread crashes.
By adding the nor-flash driver to the microkernel, the microkernel can write the stack information of the thread crash into nor-flash. When the user space crash processing thread receives the thread crash notification, it reads the stack in nor-flash. information and log it to the system log file.
The stack information of a thread crash is transferred from the microkernel to the user space of the PLC controller software, which solves the problem of being unable to obtain the stack information when a thread crashes. The logic is clear and circumvents the limitations of the microkernel operating system.
Smart Images

Figure CN114327979B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more particularly to a method and device for obtaining stack information of a thread crash. Background Art
[0002] PLC controllers are widely used in the field of process control and are very important automation control equipment. Hollysys has developed a highly secure microkernel operating system kernel (microkernel for short) based on the domestic MIPS architecture processor. The microkernel runs in the kernel space of the CPU. Hollysys has developed PLC controller software based on the microkernel, which runs in the user space of the CPU.
[0003] According to the requirements of the PLC controller software, when a thread crash occurs, the thread crash stack information must be provided for further analysis and problem location. However, the PLC controller software runs in user mode, uses virtual memory, and cannot access the microkernel's memory. The microkernel only provides five extremely primitive functions in the kernel space: thread management, inter-process communication (IPC), virtual memory space, handle space, and device base unit (interrupt object). The microkernel can identify the thread crash stack, but cannot access the PLC controller software's memory. The above two points result in the microkernel being unable to pass the thread crash stack information to the PLC controller software through memory when a thread crash occurs.
[0004] Application Contents
[0005] The present application provides a method and device for obtaining stack information of a thread crash in a user space, which can enable a user to obtain the stack information of a thread crash.
[0006] The present application proposes a method for obtaining stack information of a thread crash, comprising:
[0007] When the user space receives the thread crash notification, the crash processing thread in the user space reads the thread crash stack information in the external FLASH of the CPU;
[0008] The read stack information of the thread crash is recorded in a log file of the system, so that the user can obtain the stack information of the thread crash by reading the log file.
[0009] In an exemplary embodiment, the stack information of the thread crash is stored in the block storage space where the last first number of bytes of the external FLASH are located.
[0010] In an exemplary embodiment, the stack information of the thread crash is written into the external FLASH by the microkernel when the thread crash occurs.
[0011] In an exemplary embodiment, before the microkernel writes the stack information of the thread crash into the external FLASH, the process includes:
[0012] The initial thread of the microkernel initializes the external FLASH;
[0013] After the microkernel writes the stack information of the thread crash into the external FLASH, it includes:
[0014] Generates an interrupt to notify user space that a thread crash has occurred.
[0015] In an exemplary embodiment, the microkernel writes the stack information of the thread crash into the external FLASH, including:
[0016] The microkernel intercepts a second number of byte data in all stack information of the thread crash according to the starting stack address of the crashed thread and the value of sp;
[0017] Adding a third number of byte data headers to the second number of byte data to form stack information of the thread crash;
[0018] Erasing the block storage space where the last first number of bytes of the external FLASH are located;
[0019] Writing the stack information of the thread crash into the erased block storage space;
[0020] The first number is equal to the sum of the second number and the third number.
[0021] In an exemplary embodiment, the microkernel intercepts a second number of bytes of data from all information about the thread crash according to the starting stack address of the crashed thread and the value of sp, including:
[0022] When the difference between the starting stack address and the value of sp is greater than a second number, reading a second number of byte data starting from sp;
[0023] When the difference between the start stack address and the sp is less than or equal to a second number, the actual number of bytes is read starting from the sp.
[0024] In an exemplary embodiment, the first number is 1024; the second number is 1000; and the third number is 24.
[0025] In an exemplary embodiment, the initial thread of the microkernel initializes the external FLASH, including:
[0026] The initialization function of the external FLASH is called to implement the initialization of the external FLASH.
[0027] In an exemplary embodiment, the external FLASH includes nor-flash.
[0028] The present application provides a device for obtaining stack information of a thread crash, including a memory and a processor.
[0029] The memory is used to store a program for obtaining stack information of a thread crash;
[0030] The processor is configured to read and execute the program for obtaining the stack information of the thread crash, and perform the following operations:
[0031] When the user space receives the thread crash notification, the crash processing thread in the user space reads the thread crash stack information in the external FLASH of the CPU;
[0032] The read stack information of the thread crash is recorded in a log file of the system, so that the user can obtain the stack information of the thread crash by reading the log file.
[0033] In an exemplary embodiment, the stack information of the thread crash is stored in the block storage space where the last first number of bytes of the external FLASH are located.
[0034] In an exemplary embodiment, the stack information of the thread crash is written into the external FLASH by the microkernel when the thread crash occurs.
[0035] In an exemplary embodiment, before the microkernel writes the stack information of the thread crash into the external FLASH, the process includes:
[0036] The initial thread of the microkernel initializes the external FLASH;
[0037] After the microkernel writes the stack information of the thread crash into the external FLASH, it includes:
[0038] Generates an interrupt to notify user space that a thread crash has occurred.
[0039] In an exemplary embodiment, the microkernel writes the stack information of the thread crash into the external FLASH, including:
[0040] The microkernel intercepts a second number of byte data in all stack information of the thread crash according to the starting stack address of the crashed thread and the value of sp;
[0041] Adding a third number of byte data headers to the second number of byte data to form stack information of the thread crash;
[0042] Erasing the block storage space where the last first number of bytes of the external FLASH are located;
[0043] Writing the stack information of the thread crash into the erased block storage space;
[0044] The first number is equal to the sum of the second number and the third number.
[0045] In an exemplary embodiment, the microkernel intercepts a second number of bytes of data from all information about the thread crash according to the starting stack address of the crashed thread and the value of sp, including:
[0046] When the difference between the starting stack address and the value of sp is greater than a second number, reading a second number of byte data starting from sp;
[0047] When the difference between the start stack address and the sp is less than or equal to a second number, the actual number of bytes is read starting from the sp.
[0048] In an exemplary embodiment, the first number is 1024; the second number is 1000; and the third number is 24.
[0049] In an exemplary embodiment, the initial thread of the microkernel initializes the external FLASH, including:
[0050] The initialization function of the external FLASH is called to implement the initialization of the external FLASH.
[0051] In an exemplary embodiment, the external FLASH includes nor-flash.
[0052] At least one embodiment of the application writes the stack information of the thread crash into nor-flash through the microkernel, so that the user can obtain the stack information of the thread crash.
[0053] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by implementing the present application. Other advantages of the present application can be realized and obtained by the schemes described in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] The accompanying drawings are used to provide an understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0055] Figure 1 A flowchart of a method for obtaining stack information of a thread crash according to an embodiment of the present application;
[0056] Figure 2 This is a structural block diagram of a PLC controller according to an embodiment of the present application;
[0057] Figure 3 This is an overall flow chart of thread crash stack information recording in an embodiment of the present application;
[0058] Figure 4 A schematic diagram of a device for obtaining stack information of a thread crash according to an embodiment of the present application. DETAILED DESCRIPTION
[0059] Figure 1 This is a flow chart of a method for obtaining a thread crash address according to an embodiment of the present application. Figure 1 As shown, the method for obtaining the stack information of a thread crash in this embodiment includes steps S11-S12:
[0060] S11, when the user space receives the thread crash notification, the crash processing thread in the user space reads the thread crash stack information in the external FLASH of the CPU;
[0061] S12: Record the read stack information of the thread crash into a log file of the system, so that the user can obtain the stack information of the thread crash by reading the log file.
[0062] In an exemplary embodiment, the stack information of the thread crash is stored in the block storage space where the last first number of bytes of the external FLASH are located.
[0063] In an exemplary embodiment, the stack information of the thread crash is written into the external FLASH by the microkernel when the thread crash occurs.
[0064] In an exemplary embodiment, before the microkernel writes the stack information of the thread crash into the external FLASH, the process includes:
[0065] The initial thread of the microkernel initializes the external FLASH;
[0066] In an exemplary embodiment, after the microkernel writes the stack information of the thread crash into the external FLASH, the following steps are included:
[0067] Generates an interrupt to notify user space that a thread crash has occurred.
[0068] In an exemplary embodiment, the microkernel writes the stack information of the thread crash into the external FLASH, including:
[0069] The microkernel intercepts a second number of byte data in all stack information of the thread crash according to the starting stack address of the crashed thread and the value of sp;
[0070] Adding a third number of byte data headers to the second number of byte data to form stack information of the thread crash;
[0071] Erasing the block storage space where the last first number of bytes of the external FLASH are located;
[0072] Writing the stack information of the thread crash into the erased block storage space;
[0073] The first number is equal to the sum of the second number and the third number.
[0074] In an exemplary embodiment, the microkernel intercepts a second number of bytes of data from all information about the thread crash according to the starting stack address of the crashed thread and the value of sp, including:
[0075] When the difference between the starting stack address and the value of sp is greater than a second number, reading a second number of byte data starting from sp;
[0076] When the difference between the start stack address and the sp is less than or equal to a second number, the actual number of bytes is read starting from the sp.
[0077] In an exemplary embodiment, the first number is 1024; the second number is 1000; and the third number is 24.
[0078] In an exemplary embodiment, the initial thread of the microkernel initializes the external FLASH, including:
[0079] The initialization function of the external FLASH is called to implement the initialization of the external FLASH.
[0080] In an exemplary embodiment, the external FLASH of the CPU includes nor-flash.
[0081] In an exemplary embodiment, the log file is stored in a nand-flash outside the CPU.
[0082] In order to better understand the application content, the following is a specific description of the implementation method of transferring the stack information of a thread crash from the microkernel to the PLC controller software based on a microkernel operating system.
[0083] The crash stack recording function designed in this application mainly modifies the microkernel operating system kernel and the crash processing thread. Figure 2 PLC controller structure diagram component 12 micro-kernel operating system kernel; crash handling thread corresponding Figure 2 Part 20 of the PLC controller structure block diagram crashes the processing thread.
[0084] The difficulty of the thread crash stack recording function of the PLC controller based on the microkernel operating system designed in this application lies in finding an effective channel for transmitting information from the microkernel to the PLC controller software. The crash stack of a thread is the content saved in the thread stack when the thread crashes. Through this content combined with the code disassembly information, the user can trace back the function call process when the crash occurs. The crash stack information of a thread is usually large, at least tens of bytes. Since the microkernel operating system only provides five extremely primitive functions, and does not provide methods and interface functions for transmitting user information from the microkernel to the user space, it is difficult to pass the crash stack information of the thread from the microkernel to the PLC controller software. It is specifically divided into the following two aspects:
[0085] First, the microkernel cannot pass the crash address to the PLC controller software with the help of memory. The microkernel runs in kernel space, and the PLC controller software runs in user space. Both are virtual addresses, and the addresses are invisible. There is no channel or interface function for the microkernel and PLC controller software to share memory. Although the microkernel saves the thread's crash stack information, the microkernel cannot pass the crash stack information to the PLC controller software with the help of memory, resulting in the PLC controller software being unable to obtain the thread's crash stack information.
[0086] Second, the microkernel cannot use the CPU register to pass the crash stack information to the PLC controller software. The CPU of the Mips architecture has a total of 32 registers, and the thread crash stack is a data area, and the register simply cannot store so much data. In summary, the microkernel cannot use the CPU register to pass the crash stack information to the PLC controller software.
[0087] Since the microkernel cannot pass the crash stack information to the PLC controller software with the help of memory, and the microkernel cannot pass the crash stack information to the PLC controller software with the help of CPU registers, this application combines the characteristics of the microkernel operating system and the PLC controller software, and uses the CPU external FLASH as a channel to pass the thread crash stack information from the microkernel to the PLC controller software, thus realizing the need to pass the thread crash stack information from the microkernel to the PLC controller software. The demonstration process is as follows:
[0088] The default setting of the thread stack in the microkernel is 64KB, and the minimum is not less than 4KB. In most cases, the latest 1024 bytes of the thread stack information are intercepted, and combined with the code disassembly information, the user can trace back the function call process when the crash occurs. Since the thread crash stack information is large, it is best to store it in a non-memory exchangeable medium. The PLC controller software is designed with a file system, which can save large pieces of information in nand-flash as files. The PLC controller software is also designed with a power-off retention function, which can save large pieces of user data in binary form in nor-flash when the power is off. If the microkernel can also access nor-flash or nand-flash, the thread crash stack information can be recorded in nor-flash or nand-flash when a crash occurs, and then the thread crash stack information can be read in the crash processing thread, and this function can be realized. The microkernel can access the serial port to print some debugging information, indicating that the microkernel can access some peripherals of the CPU; the PLC controller software can also print some debugging information to the serial port, and this function does not depend on the microkernel, indicating that the PLC controller software can also access some peripherals of the CPU. From this, we can judge that both the microkernel and the PLC controller software can access some peripherals of the CPU. It is inferred that a nor-flash or nand-flash driver should be added to the microkernel to enable it to access nor-flash or nand-flash. In the PLC controller software, a file system is built on nand-flash, and the use of nand-flash is more complicated; there is no file system on nor-flash, only a simple driver, and some data is only written when the system is powered off, and some data is read when the system is powered on. Therefore, in the PLC controller software, nor-flash is much simpler to use than nand-flash, and the impact when adding functions is smaller, so it is more appropriate to choose nor-flash. To summarize, this application combines the features of the PLC controller software developed by Hollysys Corporation to build a nor-flash driver in the kernel. When a thread crash occurs, the kernel stores the thread crash stack information in nor-flash; when the crash handling thread runs, it reads the crash stack information from nor-flash, and then calls the log system to store the crash stack information in the log file located in nand-flash, thereby realizing the thread crash stack recording function of the PLC controller based on the microkernel operating system.
[0089] The thread crash stack information recording function of the PLC controller based on the microkernel operating system designed in this application includes two changes to the kernel of the microkernel operating system. When the microkernel is initialized, refer to the initialization process of the serial port and add the initialization of the nor-flash so that the microkernel can access the nor-flash. Combined with the characteristics of the PLC controller software developed by Hollysys, nor-flash only uses the front block, and the back block has not been used, so the last 1024 bytes of nor-flash are selected to store the thread crash information. When a thread crashes, the microkernel first erases the block where the last 1024 bytes of nor-flash are located, then intercepts the last 1000 bytes of the thread crash stack, and then adds a 24-byte crash stack information data header, writes it to the last 1024 bytes of nor-flash, and continues to run.
[0090] The thread crash stack information recording function of the PLC controller based on the microkernel operating system designed in this application is located in the initial thread initialization of the user space. The initialization of nor-flash has been executed before, so this application does not need to modify this module.
[0091] The thread crash stack information recording function of the PLC controller based on the microkernel operating system designed in this application includes two changes to the crash handling thread. When the crash handling thread runs, it first reads the last 1024 bytes of the nor-flash, and then calls the log interface to record the 1024 bytes into the log file. The PLC controller software has provided a log reading function, and the user can see the crash stack information by reading the log file.
[0092] The thread crash stack information recording function of the PLC controller based on the microkernel operating system designed in this application, the overall process of thread crash stack information recording is as follows Figure 3 When a crash occurs, the microkernel writes the crash stack information to the last 1024 bytes of the nor-flash; the crash handling thread reads the last 1024 bytes of the nor-flash and calls the log module to write the above 1024 bytes to the log file; then the user reads the log file through the network to obtain the crash stack information.
[0093] The present application designs a method and implementation of the thread crash stack information recording function of a PLC controller based on a microkernel operating system. The driver function of nor-flash is added to the microkernel, and a set of functions is added to the microkernel and PLC controller software, as shown below:
[0094] int os_ker_drv_init_norflash(void);
[0095] int os_ker_drv_erase_norflash_block(unsigned int offset);
[0096] int os_ker_drv_write_to_norflash(char* paddr, unsigned int len);
[0097] int os_ker_drv_read_from_norflash(char* paddr, unsigned int len);
[0098] void os_ker_init_norflash(void);
[0099] void os_ker_write_estack_to_norflash(char* paddr, unsigned int len);
[0100] unsigned int os_app_read_estack_from_norflash(char* paddr, unsigned int len);
[0101] The os_ker_init_norflash function completes the initialization of the nor - flash.
[0102] Among the above functions, the driver functions of nor-flash added in the microkernel include os_ker_drv_init_norflash, os_ker_drv_erase_norflash_block, os_ker_drv_write_to_norflash, and os_ker_drv_read_from_norflash. These functions implement the underlying initialization, data reading, and data writing functions of nor-flash respectively. This part of the code is mainly rewritten with reference to the nor-flash driver in the PLC controller software. It should be noted here that the microkernel runs in the kernel space and uses virtual addresses, and the PLC controller software runs in the user space and uses virtual addresses, so there is an independent nor-flash driver in the microkernel and the PLC controller software, and the two are invisible. The main difference between the two drivers is that the virtual addresses for accessing nor-flash are different. The virtual address of the device mapped by the os_api_mem_map function is used in the PLC controller software; the virtual address of the device in kernel state is directly used in the microkernel. Specifically for the mips architecture, the microkernel can get the virtual address of the device by adding the device physical address to 0xA0000000, which is a feature of the mips architecture. If it is an ARM or X86 architecture, the virtual address of the device must be obtained by other methods. The specific implementation idea should be to establish a mapping relationship between the physical address and the virtual address of the device in the kernel state. This application currently only fully implements the mips architecture, and does not make specific analysis and implementation for the ARM or X86 architecture.
[0103] The os_ker_init_norflash function implements the initialization function of nor-flash. This function calls the nor-flash initialization function os_ker_drv_init_norflash to initialize nor-flash.
[0104] The os_ker_write_estack_to_norflash function implements the function of writing the crash stack information to nor-flash. The function first intercepts the most recent 1000 bytes of the crash stack information. The specific interception method is: find the starting stack address and sp value (i.e., stack pointer) of the crashed thread. If the difference between the two is greater than 1000 bytes, read 1000 bytes starting from sp, otherwise read the actual number of bytes starting from sp. Add a 24-byte data header to the crash stack information. The 24-byte data header includes a 4-byte valid data length and a 20-byte reserved field. The function then calls the nor-flash erase function os_ker_drv_erase_norflash_block to erase the block where the last 1024 bytes of nor-flash are located. The function then calls the nor-flash write function os_ker_drv_write_to_norflash to write the above information to the last 1024 bytes in nor-flash.
[0105] The os_app_read_estack_from_norflash function implements the function of reading the crash stack information from nor-flash and recording it in the log. This function calls the nor-flash read function to read the last 1024 bytes of nor-flash (Note: the nor-flash read function already existed and has not been modified in this application). This function then calls the log module to write these 1024 bytes into the log file.
[0106] It should be noted here that the microkernel runs in kernel space and uses virtual addresses, and the PLC controller software runs in user space and uses virtual addresses, so there is an independent nor-flash driver in the microkernel and PLC controller software, which are called by os_ker_init_norflash, os_ker_write_estack_to_norflash, and os_app_read_estack_from_norflash respectively.
[0107] The advantages of this application are: this application closely revolves around the characteristics of the microkernel, uses NOR-Flash as an exchange medium, and passes the thread crash stack information from the microkernel to the PLC controller software, meeting the functional requirements of the product. The thread crash stack information recording function of the PLC controller based on the microkernel operating system designed by this application abandons the transmission path based on memory and CPU registers, and adopts NOR-Flash as the transmission path. The logic is clear, bypassing many limitations and difficulties of the microkernel operating system, and avoiding large-scale changes to the microkernel. The thread crash stack information recording function of the PLC controller based on the microkernel operating system designed by this application adds a set of function sets, which are relatively simple to implement.
[0108] Figure 4 Schematic diagram of a device for obtaining stack information of a thread crash according to an embodiment of the present application, such as Figure 4 As shown, a thread crash stack information device proposed in an embodiment of the present application includes a memory and a processor.
[0109] The memory is used to store a program for stack information of a thread crash;
[0110] The processor is used to read and execute the program for the stack information of the thread crash, and execute the method for the stack information of the thread crash.
[0111] The present application describes multiple embodiments, but the description is exemplary rather than restrictive, and it is obvious to those skilled in the art that there may be more embodiments and implementations within the scope of the embodiments described in the present application. Although many possible feature combinations are shown in the drawings and discussed in the specific embodiments, many other combinations of the disclosed features are also possible. Unless specifically limited, any feature or element of any embodiment may be used in combination with any other feature or element in any other embodiment, or may replace any other feature or element in any other embodiment.
[0112] The present application includes and contemplates combinations of features and elements known to those of ordinary skill in the art. The embodiments, features, and elements disclosed in the present application may also be combined with any conventional features or elements to form a unique application scheme defined by the claims. Any features or elements of any embodiment may also be combined with features or elements from other application schemes to form another unique application scheme defined by the claims. Therefore, it should be understood that any features shown and / or discussed in the present application may be implemented individually or in any appropriate combination. Therefore, except for the limitations made according to the attached claims and their equivalents, the embodiments are not subject to other restrictions. In addition, various modifications and changes may be made within the scope of protection of the attached claims.
[0113] In addition, when describing representative embodiments, the specification may have presented the method and / or process as a specific sequence of steps. However, to the extent that the method or process does not rely on the specific order of the steps described herein, the method or process should not be limited to the steps of the specific order described. As will be understood by those of ordinary skill in the art, other sequences of steps are also possible. Therefore, the specific sequence of the steps set forth in the specification should not be interpreted as a limitation to the claims. In addition, the claims for the method and / or process should not be limited to the steps of performing them in the order written, and those skilled in the art can easily understand that these sequences can be changed and still remain within the spirit and scope of the embodiments of the present application.
[0114] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
Claims
1. A method for obtaining stack information of a thread crash, characterized in that: When the user space receives the thread crash notification, the crash processing thread in the user space reads the thread crash stack information in the external FLASH of the CPU; and recording the read stack information of the thread crash to a log file of the system, so that a user can obtain the stack information of the thread crash by reading the log file; Wherein, the stack information of the thread crash is written into the external FLASH by the microkernel when the thread crash occurs; Before the microkernel writes the stack information of the thread crash into the external FLASH, the method includes: The initial thread of the microkernel initializes the external FLASH so that the microkernel can access the external FLASH; After the microkernel writes the stack information of the thread crash into the external FLASH, it includes: Generates an interrupt to notify user space that a thread crash has occurred.
2. The method of claim 1, comprising: The stack information of the thread crash is stored in the block storage space where the last first number of bytes of the external FLASH are located.
3. The method according to claim 1, wherein the microkernel writes the stack information of the thread crash to the external FLASH, comprising: The microkernel intercepts a second number of byte data in all stack information of the thread crash according to the starting stack address of the crashed thread and the value of the stack pointer; Adding a third number of byte data headers to the second number of byte data to form stack information of the thread crash; Erasing the block storage space where the last first number of bytes of the external FLASH are located; Writing the stack information of the thread crash into the erased block storage space; The first number is equal to the sum of the second number and the third number.
4. The method according to claim 3, wherein the microkernel intercepts a second amount of byte data from all information about the thread crash according to the starting stack address of the crashed thread and the value of the stack pointer, comprising: When the difference between the starting stack address and the value of the stack pointer is greater than a second quantity, reading a second quantity of byte data starting from the stack pointer; When the difference between the start stack address and the stack pointer is less than or equal to a second number, the actual number of bytes is read starting from the stack pointer.
5. The method according to claim 3, characterized in that: The first number is 1024; the second number is 1000; and the third number is 24.
6. The method according to claim 1, characterized in that: The initial thread of the microkernel initializes the external FLASH, including: The initialization function of the external FLASH is called to implement the initialization of the external FLASH.
7. The method according to any one of claims 1 to 6, characterized in that: The external FLASH includes nor-flash.
8. A device for obtaining stack information of a thread crash, comprising a memory and a processor, characterized in that: The memory is used to store a program for obtaining stack information of a thread crash; The processor is used to read and execute the program for obtaining the stack information of the thread crash, and execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Kernel function calling stack analyzing and debugging method in case of Linux system breakdown
CN103106132A
Method and apparatus for management of mapped and unmapped regions of memory in a microkernel data processing system
US5729710A