Abnormality processing method and device, electronic equipment, chip and medium
By identifying and merging the kernel's abnormal data physical pages and generating a kernel dump file, the system crash and data loss problems caused by abnormal kernel termination are solved, the efficiency and accuracy of kernel exception handling are improved, and the system stability and data security are ensured.
Patent Information
- Application Number
- CN202510646953.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-19
- Publication Date
- 2025-09-30
AI Technical Summary
In the prior art, abnormal kernel termination causes system crashes and data loss. Existing kernel dump solutions have problems such as large data volumes or omissions of key information, which affect system stability and data security.
By identifying the physical pages where abnormal data of the target operating system kernel is located, a kernel dump file is generated. Dynamic merging and sorting technology is used to reduce the number of ELF program segments and improve the effectiveness and generation efficiency of the kernel dump file.
It achieves fast and accurate capture of kernel exception data, improves the efficiency and accuracy of kernel exception handling, and ensures system stability and data security.
Smart Images

Figure CN120723510A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to an exception handling method, device, electronic device, chip, and medium. Background Art
[0002] As computer systems continue to expand, hardware architectures become more complex, and application requirements become more diverse, the kernel's workload becomes increasingly burdensome, and its operating environment becomes increasingly complex and unpredictable. This increase in the likelihood of kernel abnormal terminations can lead to serious consequences, such as system crashes, data loss, and service interruptions, posing a significant threat to the stability, reliability, and security of computer systems. Therefore, establishing an efficient and reliable mechanism for handling kernel abnormal terminations is crucial. Such a mechanism not only ensures the continued stable operation of computer systems, but also significantly improves the user experience and effectively maintains data security. Summary of the Invention
[0003] This application aims to solve one of the technical problems in the related art to a certain extent.
[0004] To this end, the present application proposes an exception handling method, device, electronic device, chip and medium to achieve rapid capture of exception data of the kernel of the target operating system, providing a rich and critical data basis for kernel exception handling, and improving the efficiency and accuracy of kernel exception handling.
[0005] In one aspect, an embodiment of the present application provides an exception handling method, including:
[0006] In response to detecting that an abnormal termination occurs in a kernel running a target operating system, identifying a first physical page from the physical memory of the kernel; wherein the storage data of the first physical page includes abnormal data of the running kernel;
[0007] A kernel dump file of the kernel is generated according to the storage data of the first physical page; wherein the kernel dump file is used to perform exception processing on the kernel.
[0008] Another embodiment of the present application provides an exception handling device, comprising:
[0009] an identification module configured to, in response to detecting abnormal termination of a kernel running a target operating system, identify a first physical page from the physical memory of the kernel; wherein the storage data of the first physical page includes abnormal data of the kernel;
[0010] A generation module is used to generate a kernel dump file of the kernel according to the storage data of the first physical page; wherein the kernel dump file is used to perform exception processing on the kernel.
[0011] In another aspect, an embodiment of the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0012] The memory stores computer-executable instructions;
[0013] The processor executes the computer-executable instructions stored in the memory to implement the exception handling method described in an embodiment of one aspect of the present application.
[0014] In yet another aspect, an embodiment of the present application provides a chip, the chip including a processing circuit, the processing circuit being configured to execute the exception handling method as described in the embodiment of the first aspect.
[0015] In another aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by a processor, they are used to implement the exception handling method as described in the embodiment of the first aspect.
[0016] In yet another aspect, an embodiment of the present application provides a computer program product having a computer program stored thereon, which implements the exception handling method as described in the embodiment of the first aspect when the program is executed by a processor.
[0017] The exception handling method, device, electronic device, chip and medium proposed in this application, by identifying the first physical page containing the kernel's abnormal data from the kernel's physical memory when detecting that the kernel running the target operating system has terminated abnormally, and generating a kernel dump file of the running kernel based on the storage data of the first physical page, thereby achieving rapid and accurate capture of the kernel's abnormal data of the target operating system, providing a rich and critical data basis for the kernel's exception handling, and improving the efficiency and accuracy of the kernel's exception handling.
[0018] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0020] Figure 1 A flowchart of an exception handling method provided in an embodiment of the present application;
[0021] Figure 2A flowchart of another exception handling method provided in an embodiment of the present application;
[0022] Figure 3 A flowchart of another exception handling method provided in an embodiment of the present application;
[0023] Figure 4 A flowchart of another exception handling method provided in an embodiment of the present application;
[0024] Figure 5 A flowchart of another exception handling method provided in an embodiment of the present application;
[0025] Figure 6 A schematic diagram illustrating the principle of an exception handling method provided in an embodiment of the present application;
[0026] Figure 7 A schematic diagram of the structure of an exception handling device provided in an embodiment of the present application;
[0027] Figure 8 A block diagram of an electronic device provided in an embodiment of the present application;
[0028] Figure 9 It is a schematic diagram of the structure of the chip proposed in the embodiment of this application. DETAILED DESCRIPTION
[0029] The following describes in detail embodiments of the present application, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0030] Kernel maintenance and testing of operating systems (such as Linux) refers to the process of testing, debugging, and verifying the operating system kernel. As operating system kernels continue to develop and their application scenarios continue to expand, operating system kernel maintenance and testing are also evolving.
[0031] On the one hand, the testing methods and tools for operating system kernel maintenance and testing are constantly being updated and improved. For example, the operating system kernel community continues to launch new testing frameworks and tools, which can help developers test and debug faster and more accurately.
[0032] On the other hand, the application scenarios for operating system kernel maintenance and testing are also expanding. As the operating system kernel becomes increasingly widely used in various fields, the requirements for its reliability and stability are also becoming increasingly stringent. Therefore, operating system kernel maintenance and testing must focus not only on basic functional testing but also on performance, security, and reliability testing.
[0033] Currently, the kernel dump solutions of system-on-a-chip (SOC) manufacturers of electronic devices (such as mobile phones) mainly adopt the following two modes:
[0034] The first mode, Full Dump, dumps the entire physical memory data. Its advantage is that it fully records all information at the crash site, providing comprehensive support for problem analysis. However, its disadvantage is that the large amount of data leads to excessive storage space usage and low transmission efficiency.
[0035] The second mode: Selected Area Dump (Mini Dump): Only dumps data from a specific area defined by the user. This mode has a small data size and convenient transmission, but relies on manual selection of the area range, which can easily miss key information and lead to insufficient support for problem analysis.
[0036] It should be noted that no matter which mode is used, the kernel dump ultimately needs to rely on parsing tools to restore the crash scene, so the dump content must be organized into a parseable file format.
[0037] In related technologies, kernel dump files are Executable and Linkable Format (ELF) files of the core dump (ET_CORE) type. Each dump area (one physical page) corresponds to a program segment in the ELF file, but there is a limit of 65,536 program segments. If further miniaturization is required based on a full memory dump, such as by filtering and reducing data by filtering key areas, the excessive number of dump areas may prevent the file from being organized into an ELF file, leading to improper data organization and parsing failure.
[0038] In response to the above problems, the present application proposes an exception handling method, device, electronic device, chip and medium.
[0039] The following describes the exception handling method, device, electronic device, chip, and medium according to the embodiments of the present application with reference to the accompanying drawings.
[0040] Figure 1 A flowchart of an exception handling method provided in an embodiment of the present application.
[0041] It should be noted that the exception handling method of the embodiment of the present application can be applied to an exception handling device. In some possible embodiments, the exception handling device can be configured in an electronic device or chip so that the electronic device or chip can perform the exception handling function. In addition, in some possible embodiments, the exception handling device can also be software or a unified extensible firmware interface (UEFI) in the electronic device.
[0042] In any embodiment of the present application, the chip can be integrated into an electronic device. Among them, the chip includes a central processing unit (CPU), an image signal processing (ISP), an application-specific integrated circuit (ASIC), a microprocessor (DSP), a field programmable gate array (FPGA), a system on a chip, a reduced instruction set computer (RISC), etc., which are not listed one by one here.
[0043] like Figure 1 As shown, the exception handling method may include the following steps:
[0044] Step 101 : In response to detecting that an abnormal termination occurs in a kernel running a target operating system, a first physical page is identified from a physical memory of the kernel.
[0045] The storage data of the first physical page includes abnormal data of the kernel.
[0046] It should be understood that the physical memory of the kernel of the target operating system stores all runtime data, such as program code, stack information, register status, etc.
[0047] Therefore, in order to improve the efficiency and accuracy of exception handling, in an embodiment of the present application, when it is detected that the kernel running the target operating system (such as LINUX) sends an abnormal termination (such as a crash), the physical page of the storage data including the kernel's abnormal data, i.e., the first physical page, is identified from the kernel's physical memory.
[0048] Step 102: Generate a kernel dump file of the kernel according to the storage data of the first physical page.
[0049] The core dump file is used to handle kernel exceptions.
[0050] In an embodiment of the present application, the storage data in the first physical page is extracted and saved to a kernel dump file, wherein the kernel dump file is used to record the memory state when the kernel terminates abnormally. The kernel dump file can serve as a "memory snapshot" of the kernel at the moment of abnormal termination.
[0051] It is important to understand that kernel dump files are used to troubleshoot abnormal kernel terminations. By analyzing kernel dump files, you can promptly understand the specific location where the abnormal kernel termination occurred, the operating environment at the time, and possible triggering causes, so as to perform kernel exception handling.
[0052] For example, if Figure 2 As shown, taking the target operating system on a mobile phone as an example, some applications and services are running on the target operating system; at a certain moment, due to some reason, the target operating system crashes, causing the applications and services to fail to run normally; when the target operating system crashes, the exception handling mechanism is triggered and a kernel dump file is generated. Then, relevant crash analysis tools are used to analyze and debug the kernel dump information in the kernel dump file to quickly locate the problem and repair it.
[0053] In summary, by identifying the first physical page containing the kernel's abnormal data from the kernel's physical memory when detecting that the kernel running the target operating system has terminated abnormally, and generating a kernel dump file of the running kernel based on the storage data of the first physical page, the abnormal data of the kernel of the target operating system can be captured quickly and accurately, providing a rich and critical data basis for the kernel's exception handling, and improving the efficiency and accuracy of the kernel's exception handling.
[0054] In order to clearly illustrate how the kernel dump file of the kernel is generated according to the storage data of the first physical page in the above embodiment, the present application proposes another exception handling method.
[0055] Figure 3 A flowchart of another exception handling method provided in an embodiment of the present application.
[0056] like Figure 3 As shown, the exception handling method may include the following steps:
[0057] Step 301 : In response to detecting that an abnormal termination occurs in a kernel running a target operating system, a first physical page is identified from a physical memory of the kernel.
[0058] The storage data of the first physical page includes abnormal data of the kernel.
[0059] Step 302 : When the number of first physical pages is greater than a set threshold, merge the first physical pages at least once to obtain second physical pages.
[0060] It should be understood that since one physical page corresponds to one ELF program segment, but there is a limit on the number of ELF program segments (e.g., 65536); therefore, in order to avoid the inability to accurately generate a kernel dump file, in an embodiment of the present application, it is determined whether the number of first physical pages is greater than a set threshold (e.g., 65536). If the number of first physical pages is greater than the set threshold, the first physical page needs to be merged at least once to obtain a second physical page to reduce the number of ELF program segments.
[0061] Step 303: Generate a kernel dump file of the kernel based on the storage data in the second physical page.
[0062] Furthermore, an ELF program segment is created based on the storage data in the merged second physical pages, and a kernel dump file is generated based on the ELF program segment corresponding to each second physical page.
[0063] That is to say, an ELF program segment is created for each second physical page, and all the ELF program segments are merged into a complete file, that is, a kernel dump file is obtained.
[0064] In summary, by dynamically merging the first physical page, the number of program segments is effectively reduced, thereby improving the effectiveness and generation efficiency of the kernel dump file, and further improving the efficiency and accuracy of kernel exception handling.
[0065] In order to clearly illustrate how the first physical page is merged at least once to obtain the second physical page in the above embodiment, the present application proposes another exception handling method.
[0066] Figure 4 A flowchart of another exception handling method provided in an embodiment of the present application.
[0067] like Figure 4 As shown, the exception handling method may include the following steps:
[0068] Step 401 : In response to detecting that an abnormal termination occurs in a kernel running a target operating system, a first physical page is identified from a physical memory of the kernel.
[0069] The storage data of the first physical page includes abnormal data of the kernel.
[0070] Step 402 : Sort the first physical pages according to their physical addresses to obtain a first sequence.
[0071] It should be understood that each physical page has a unique physical address that identifies its location in the physical memory. In order to more efficiently process the stored data in the first physical page, in an embodiment of the present application, the first physical page is sorted from small to large according to the physical address to obtain a first sequence.
[0072] Step 403: Determine the number of interval pages between any two adjacent first physical pages in the first sequence.
[0073] In order to reduce data in the kernel dump file that is not related to abnormal termination and to improve the efficiency and accuracy of exception handling, in an embodiment of the present application, the number of pages between any two adjacent first physical pages in the first sequence is used to identify which first physical pages are closer to each other, and first physical pages with closer distances are merged first.
[0074] In an embodiment of the present application, in the first sequence, any two adjacent first physical pages have clear physical addresses. By calculating the difference between the physical addresses of the two adjacent first physical pages, the total number of bytes between the two adjacent first physical pages can be obtained. The size of each physical page in the physical memory is set (for example, 4KB, i.e., 4096 bytes). Therefore, based on the total number of bytes between the two adjacent first physical pages and the set size of each physical page, the number of interval pages between the two adjacent first physical pages can be calculated.
[0075] Step 404 : sort the number of pages in each interval from small to large to obtain a second sequence.
[0076] In order to preferentially merge the first physical pages that are closer, as a possible implementation method, the numbers of the interval pages may be sorted from small to large to obtain a second sequence.
[0077] Step 405 : Based on the number of interval pages in the second sequence, merge the first physical page at least once to obtain a second physical page.
[0078] Furthermore, based on the number of interval pages in the second sequence, the interval between two adjacent first physical pages in the first sequence can be clarified, so that the physical pages with smaller intervals can be merged first.
[0079] As a possible implementation, based on the number of interval pages in the second sequence, the first physical page is merged at least once to obtain a second physical page obtained by the final merge. That is, the i-th merge is performed based on the second physical page obtained by the i-1-th merge. Where i is a positive integer greater than 1.
[0080] Wherein, for the first merger in at least one merger, the following steps are included:
[0081] (1) when the number of first physical pages is greater than a set threshold, determining the physical pages to be merged for the first time from each first physical page; wherein the number of interval pages between the physical pages to be merged for the first time is the first number of interval pages in the second sequence;
[0082] In an embodiment of the present application, when the number of first physical pages is greater than a set threshold, the first number of interval pages in the second sequence is the minimum number of pages between the first physical pages in the first sequence, and all first physical pages in the first sequence whose number of interval pages is the first number of interval pages are used as the physical pages to be merged for the first time.
[0083] (2) The physical page to be merged for the first time and the intermediate physical page between the physical pages to be merged for the first time are merged to obtain a second physical page obtained by the first merger.
[0084] Then, the physical pages to be merged for the first time and the intermediate physical pages between the physical pages to be merged for the first time are merged to obtain a second physical page obtained by the first merger; wherein the second physical page obtained by the first merger includes a physical page obtained by merging the physical pages to be merged for the first time and the unmerged first physical page; and the memory size of the second physical page is greater than or equal to the memory size of the first physical page.
[0085] Wherein, for the i-th merger in at least one merger, the following steps are included:
[0086] (1) When the number of second physical pages obtained in the (i-1)th merge is less than or equal to the set threshold, the merge is terminated;
[0087] As an example, each second physical page corresponds to an ELF program segment. When the number of second physical pages obtained in the (i-1)th merge is less than or equal to a set threshold, the number of ELF program segments is less than the set threshold, and the merge is terminated. Based on the ELF program segments corresponding to each second physical page, a core dump file can be effectively generated.
[0088] (2) when the number of second physical pages obtained by the (i-1)th merge is greater than a set threshold, determining the physical page to be merged for the i-th time from the second physical pages obtained by the (i-1)th merge; wherein i is a positive integer greater than 1, and the number of interval pages of the physical page to be merged for the i-th time is the number of the i-th interval page in the second sequence;
[0089] As another example, when the number of second physical pages obtained by the (i-1)th merge is greater than a set threshold, a physical page whose number of interval pages is the i-th number of interval pages in the second sequence is further determined from the second physical pages obtained by the (i-1)th merge as the physical page to be merged for the i-th time.
[0090] (3) The physical page to be merged for the i-th time and the intermediate physical page between the physical pages to be merged for the i-th time are merged to obtain a second physical page obtained by the i-th merger.
[0091] Furthermore, the intermediate physical page between the physical page to be merged for the i-th time and the physical page to be merged for the ith time is merged to obtain a second physical page obtained by the i-th merger, wherein the second physical page obtained by the i-th merger includes the physical page obtained by merging the physical page to be merged for the i-th time and the physical pages of the second physical page obtained by the (i-1)-th merger except the physical page to be merged for the i-th time.
[0092] As another possible implementation, different merge strategies are pre-set, and the first physical pages are merged according to the different merge strategies to obtain second physical pages merged according to each merge strategy. For example, the merge strategy may be to merge according to the utilization of the first physical pages, merging first physical pages with a utilization less than 50%. Another example is to merge according to the priority of the first physical pages, prioritizing the first physical pages and merging first physical pages with priorities greater than a set priority threshold to obtain second physical pages. Furthermore, the number of second physical pages obtained by merging according to the different merge strategies is determined, and the second physical pages with a number less than the set threshold are selected as the second physical pages ultimately used to generate the kernel dump file.
[0093] Step 406: Generate a kernel dump file of the kernel based on the storage data in the second physical page.
[0094] It should be noted that the execution process of step 401 and step 406 can be implemented in any of the embodiments of the present application. The embodiments of the present application do not limit this and will not be described in detail.
[0095] In summary, based on the first sequence obtained by sorting the first physical pages, the number of interval pages between any two adjacent first physical pages in the first sequence is determined, thereby improving the accuracy of the number of interval pages. Therefore, based on the number of interval pages in the second sequence, the first physical page is merged at least once to obtain the second physical page. This achieves the goal of integrating multiple scattered physical pages together to form a larger physical page in memory while effectively reducing data in the kernel dump file that is not related to the abnormal termination. Therefore, based on the second physical page, a kernel dump file is generated, thereby improving the efficiency and accuracy of kernel exception handling.
[0096] In order to clearly illustrate how the kernel dump file of the kernel is generated based on the storage data in the second physical page in the above embodiment, the present disclosure proposes another exception handling method.
[0097] Figure 5A flowchart of another exception handling method provided in an embodiment of the present application.
[0098] like Figure 5 As shown, the exception handling method includes the following steps:
[0099] Step 501 : In response to detecting that an abnormal termination occurs in a kernel running a target operating system, a first physical page is identified from a physical memory of the kernel.
[0100] The storage data of the first physical page includes abnormal data of the kernel.
[0101] Step 502 : When the number of the first physical pages is greater than a set threshold, merge the first physical pages at least once to obtain a second physical page.
[0102] Step 503: Create an ELF program segment corresponding to any second physical page according to the storage data of any second physical page.
[0103] As a possible implementation manner, the merged second physical pages include at least one second physical page. For any second physical page in the at least one second physical page, the storage data in the any second physical page is organized according to the requirements of the ELF format to generate a corresponding ELF program segment.
[0104] Step 504: Generate a kernel dump file based on the ELF program segments corresponding to each second physical page.
[0105] Then, all ELF program segments corresponding to the second physical pages and other related information are combined into one file to obtain a kernel dump file.
[0106] As another possible implementation, when the number of first physical pages is less than or equal to a set threshold, an ELF program segment corresponding to any first physical page is created based on the storage data of the first physical page; and a kernel dump file is generated based on the ELF program segment corresponding to each first physical page.
[0107] That is to say, since one physical page corresponds to one ELF program segment in the process of generating a kernel dump file, when the number of first physical pages is less than or equal to a set threshold, an ELF program segment corresponding to any first physical page is created directly based on the storage data of the first physical page, and the ELF program segments corresponding to all first physical pages and other related information are combined into one file to obtain a kernel dump file.
[0108] In summary, by converting physical page data into standardized ELF program segments and generating a kernel dump file, the memory state is saved in a structured and parseable format. This allows different tools (such as debuggers and disassemblers) to directly process the dump data without the need for additional parsing logic, thereby improving the efficiency of kernel exception handling.
[0109] In any embodiment of the present application, Figure 6 As shown, the exception handling method of the embodiment of the present application can also be implemented based on the following steps:
[0110] 1. When detecting that the kernel running the target operating system sends an abnormal termination, the page descriptor of each physical page of the physical memory of the kernel is parsed to obtain page metadata of each physical page, and based on the page metadata of each physical page, an abnormal data storage area (first physical page) for storing the kernel and a non-abnormal data storage area (non-dump area) for storing the non-abnormal data are identified from each physical page;
[0111] 2. When the number of abnormal data storage areas is greater than a set threshold (65536), the abnormal data storage areas are merged at least once until the number of abnormal data storage areas obtained by the merger is less than or equal to the set threshold;
[0112] 3. Organize the stored data in the abnormal data storage area obtained based on the last merge into an ELF file.
[0113] With the above Figures 1 to 6 Corresponding to the exception handling method provided in the embodiment, the present disclosure also provides an exception handling device. Figures 1 to 6 The exception handling method provided in the embodiment corresponds to the above, so the implementation of the exception handling method is also applicable to the exception handling device provided in the embodiment of the present disclosure, and will not be described in detail in the embodiment of the present disclosure.
[0114] Figure 7 A schematic diagram of the structure of an exception handling device provided in an embodiment of the present application.
[0115] like Figure 7 As shown, the exception handling device 700 includes: an identification module 710 and a generation module 720.
[0116] Among them, the identification module 710 is used to identify a first physical page from the physical memory of the kernel in response to detecting an abnormal termination of the kernel running the target operating system; wherein the storage data of the first physical page includes the abnormal data of the kernel; the generation module 720 is used to generate a kernel dump file of the kernel based on the storage data of the first physical page; wherein the kernel dump file is used to perform exception processing on the kernel.
[0117] As a possible implementation method, the generation module 720 is used to merge the first physical pages at least once to obtain the second physical page when the number of the first physical pages is greater than a set threshold; and generate a kernel dump file of the kernel based on the storage data in the second physical page.
[0118] As a possible implementation method, the generation module 720 is used to sort the first physical pages according to the physical addresses of the first physical pages to obtain a first sequence; determine the number of interval pages between any two adjacent first physical pages in the first sequence; sort the number of each interval page from small to large to obtain a second sequence; and merge the first physical pages at least once based on the number of interval pages in the second sequence to obtain a second physical page.
[0119] As a possible implementation method, the generation module 720 performs the first merge in at least one merge, specifically: determining the physical page to be merged for the first time from each first physical page; wherein the number of interval pages between the physical pages to be merged for the first time is the first number of interval pages in the second sequence; merging the physical page to be merged for the first time and the intermediate physical page between the physical page to be merged for the first time to obtain the second physical page obtained by the first merge.
[0120] As a possible implementation method, the generation module 720 performs the i-th merge in at least one merge, specifically: when the number of second physical pages obtained in the i-1-th merge is less than or equal to the set threshold, the merge is terminated; when the number of second physical pages obtained in the i-1-th merge is greater than the set threshold, the i-th physical page to be merged is determined from the second physical pages obtained in the i-1-th merge; wherein i is a positive integer greater than 1, and the number of interval pages of the i-th physical page to be merged is the i-th number of interval pages in the second sequence; the intermediate physical page between the i-th physical page to be merged and the i-th physical page to be merged is merged to obtain the second physical page obtained in the i-th merge.
[0121] As a possible implementation, the generation module 720 is configured to create an executable and linkable ELF program segment corresponding to any second physical page according to the storage data of any second physical page; and generate a kernel dump file based on the ELF program segment corresponding to each second physical page.
[0122] As a possible implementation, the exception handling device 700 further includes: a creation module.
[0123] Among them, the creation module is used to create an ELF program segment corresponding to any first physical page based on the storage data of the first physical page when the number of first physical pages is less than or equal to the set threshold; the generation module 720 is used to generate a kernel dump file based on the ELF program segment corresponding to each first physical page.
[0124] As a possible implementation method, the identification module 710 is used to parse the page descriptors of each physical page of the physical memory in response to detecting an abnormal termination of the kernel running the target operating system to obtain page metadata of each physical page; based on the page metadata of each physical page, identify the first physical page for storing the abnormal data of the kernel from each physical page.
[0125] The exception handling device of the embodiment of the present application, by identifying the first physical page containing the kernel's abnormal data from the kernel's physical memory when detecting that the kernel running the target operating system has terminated abnormally, and generating a kernel dump file of the running kernel based on the storage data of the first physical page, achieves rapid and accurate capture of the kernel's abnormal data of the target operating system, provides a rich and critical data basis for the kernel's exception handling, and improves the efficiency and accuracy of the kernel's exception handling.
[0126] In order to implement the above embodiments, the present disclosure also proposes an electronic device, including a processor and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the exception handling method described in the above embodiments.
[0127] In order to implement the above embodiments, the present disclosure further proposes a chip, which includes a processing circuit, and the processing circuit is configured to execute the exception handling method as described in the above method embodiment.
[0128] In order to implement the above embodiments, the present disclosure further proposes a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the exception handling method described in the above method embodiments.
[0129] In order to implement the above embodiments, the present disclosure further proposes a computer program product on which a computer program is stored. When the computer program is executed by a processor, the exception handling method as described in the above method embodiments is implemented.
[0130] Figure 8 This is a block diagram of an electronic device provided in an embodiment of the present application. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0131] Reference Figure 8 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .
[0132] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operation, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 802 may include one or more modules to facilitate interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
[0133] The memory 804 is configured to store various types of data to support operations on the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.
[0134] The power component 806 provides power to the various components of the electronic device 800. The power component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800.
[0135] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor can not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each front camera and rear camera can be a fixed optical lens system or have a focal length and optical zoom capability.
[0136] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), which is configured to receive external audio signals when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0137] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as a keyboard, click wheel, buttons, etc. These buttons may include but are not limited to: a home button, volume buttons, a start button, and a lock button.
[0138] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the electronic device 800, the relative positioning of components, such as the display and keypad of the electronic device 800. The sensor assembly 814 can also detect changes in the position of the electronic device 800 or a component of the electronic device 800, the presence or absence of user contact with the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and temperature changes of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0139] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, 4G or 5G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0140] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0141] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by the processor 820 of the electronic device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0142] Figure 9 This is a schematic diagram of the structure of the chip proposed in the embodiment of this application. Figure 8 The structure of the chip 900 is shown, but is not limited thereto.
[0143] The chip 900 includes a processing circuit 901 , which is configured to execute any of the above methods.
[0144] In some embodiments, chip 900 further includes one or more interface circuits 902. Optionally, interface circuit 902 is connected to memory 903. Interface circuit 902 can be used to receive signals from memory 903 or other devices, and can be used to send signals to memory 903 or other devices. For example, interface circuit 902 can read instructions stored in memory 903 and send the instructions to processing circuit 901.
[0145] In some embodiments, the interface circuit 902 performs at least one of the communication steps such as sending and / or receiving in the above method, and the processing circuit 901 performs the other steps.
[0146] In some embodiments, terms such as interface circuit, interface, transceiver pin, and transceiver may be used interchangeably.
[0147] In some embodiments, the chip 900 further includes one or more memories 903 for storing instructions. Alternatively, all or part of the memories 903 may be located outside the chip 900 .
[0148] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.
[0149] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of such features. Throughout the description of this application, "plurality" means at least two, for example, two, three, etc., unless otherwise specifically defined.
[0150] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may be performed out of the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present application belong.
[0151] The logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic devices), a portable computer disk cartridge (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and a portable compact disc read-only memory (CDROM). Furthermore, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing it in another suitable manner if necessary, and then storing it in a computer memory.
[0152] It should be understood that various parts of the present application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used to implement: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application-specific integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0153] Those skilled in the art will understand that all or part of the steps in the method of the above embodiment can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiment.
[0154] In addition, the functional units in the various embodiments of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into a module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0155] The storage medium mentioned above may be a read-only memory, a magnetic disk, or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present application. Persons skilled in the art may make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present application.
Claims
1. An exception handling method, characterized in that: include: In response to detecting that an abnormal termination occurs in a kernel running a target operating system, identifying a first physical page from the physical memory of the kernel; wherein the storage data of the first physical page includes abnormal data of the kernel; A kernel dump file of the kernel is generated according to the storage data of the first physical page; wherein the kernel dump file is used to perform exception processing on the kernel.
2. The method according to claim 1, characterized in that Generating a kernel dump file of the kernel according to the storage data of the first physical page includes: When the number of the first physical pages is greater than a set threshold, merging the first physical pages at least once to obtain a second physical page; A kernel dump file of the kernel is generated based on the stored data in the second physical page.
3. The method according to claim 2, characterized in that The merging the first physical page at least once to obtain the second physical page includes: sorting the first physical pages according to the physical addresses of the first physical pages to obtain a first sequence; determining the number of interval pages between any two adjacent first physical pages in the first sequence; Sort the number of each of the interval pages from small to large to obtain a second sequence; Based on the number of interval pages in the second sequence, the first physical page is merged at least once to obtain a second physical page.
4. The method according to claim 3, characterized in that The first merger in the at least one merger includes: Determining physical pages to be merged for the first time from each of the first physical pages; wherein the number of interval pages between the physical pages to be merged for the first time is the first number of interval pages in the second sequence; The physical page to be merged for the first time and the intermediate physical page between the physical pages to be merged for the first time are merged to obtain the second physical page obtained by the first merger.
5. The method according to claim 4, characterized in that The i-th merger in the at least one merger includes: When the number of second physical pages obtained by the (i-1)th merge is less than or equal to the set threshold, the merge is terminated; When the number of second physical pages obtained by the (i-1)th merge is greater than the set threshold, determining the physical pages to be merged for the i-th time from the second physical pages obtained by the (i-1)th merge; wherein i is a positive integer greater than 1, and the number of interval pages between the physical pages to be merged for the i-th time is the number of the i-th interval pages in the second sequence; The physical page to be merged for the i-th time and the intermediate physical page between the physical pages to be merged for the i-th time are merged to obtain a second physical page obtained by the i-th merger.
6. The method according to claim 2, characterized in that Generating a kernel dump file of the kernel based on the storage data in the second physical page includes: Creating an executable and linkable format ELF program segment corresponding to any second physical page according to the storage data of the second physical page; The kernel dump file is generated based on the ELF program segments corresponding to each of the second physical pages.
7. The method according to claim 2, characterized in that The method further comprises: When the number of the first physical pages is less than or equal to the set threshold, creating an ELF program segment corresponding to any one of the first physical pages based on the storage data of the first physical pages; The kernel dump file is generated based on the ELF program segments corresponding to each of the first physical pages.
8. The method according to claim 1, characterized in that In response to detecting that an abnormal termination occurs in a kernel running the target operating system, identifying at least one first physical page from the physical memory of the kernel includes: In response to detecting that an abnormal termination occurs on a kernel running the target operating system, parsing a page descriptor of each physical page of the physical memory to obtain page metadata of each physical page; A first physical page for storing abnormal data of the kernel is identified from each of the physical pages according to the page metadata of each of the physical pages.
9. An exception handling device, characterized in that: The device comprises: an identification module configured to, in response to detecting abnormal termination of a kernel running a target operating system, identify a first physical page from the physical memory of the kernel; wherein the storage data of the first physical page includes abnormal data of the kernel; A generation module is used to generate a kernel dump file of the kernel according to the storage data of the first physical page; wherein the kernel dump file is used to perform exception processing on the kernel.
10. The device according to claim 9, characterized in that The generating module is used to: When the number of the first physical pages is greater than a set threshold, merging the first physical pages at least once to obtain a second physical page; A kernel dump file of the kernel is generated based on the stored data in the second physical page.
11. The device according to claim 10, characterized in that The generating module is used to: sorting the first physical pages according to the physical addresses of the first physical pages to obtain a first sequence; determining the number of interval pages between any two adjacent first physical pages in the first sequence; Sort the number of each of the interval pages from small to large to obtain a second sequence; Based on the number of interval pages in the second sequence, the first physical page is merged at least once to obtain a second physical page.
12. The device according to claim 11, characterized in that The generating module performs the first merge in the at least one merge, specifically: Determining physical pages to be merged for the first time from each of the first physical pages; wherein the number of interval pages between the physical pages to be merged for the first time is the first number of interval pages in the second sequence; The physical page to be merged for the first time and the intermediate physical page between the physical pages to be merged for the first time are merged to obtain the second physical page obtained by the first merger.
13. The device according to claim 12, characterized in that The generating module performs the i-th merge in the at least one merge, specifically: When the number of second physical pages obtained by the (i-1)th merge is less than or equal to the set threshold, the merge is terminated; When the number of second physical pages obtained by the (i-1)th merge is greater than the set threshold, determining the physical pages to be merged for the i-th time from the second physical pages obtained by the (i-1)th merge; wherein i is a positive integer greater than 1, and the number of interval pages between the physical pages to be merged for the i-th time is the number of the i-th interval pages in the second sequence; The physical page to be merged for the i-th time and the intermediate physical page between the physical pages to be merged for the i-th time are merged to obtain a second physical page obtained by the i-th merger.
14. The device according to claim 10, characterized in that The generating module is used to: Creating an executable and linkable format ELF program segment corresponding to any second physical page according to the storage data of the second physical page; The kernel dump file is generated based on the ELF program segments corresponding to each of the second physical pages.
15. An electronic device, characterized in that: include: a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 8.
16. A chip, characterized in that: The chip comprises a processing circuit configured to perform the method according to any one of claims 1 to 8.
17. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 8 when executed by a processor.
