File generation method and device, computer equipment and storage medium
By traversing the virtual memory space in the embedded device and allocating memory usage to generate the target Core Dump file, the problem of stack information loss caused by Core Dump file truncation is solved, thus achieving accurate problem location and file validity.
Patent Information
- Application Number
- CN202510983373.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-16
- Publication Date
- 2025-11-07
AI Technical Summary
In embedded devices, due to limited storage resources, the maximum size limit of Core Dump files causes files to be truncated, resulting in incomplete preservation of stack information and affecting the accuracy of problem localization and analysis.
By traversing multiple virtual memory spaces in the process, the total amount of memory data that needs to be transferred is determined, the memory usage of stack data and other anonymous page memory data is allocated, and the target kernel transfer file is generated, ensuring that the stack data is completely preserved and other anonymous page memory data is retained to the greatest extent.
This ensures the complete preservation of stack data, improves the accuracy of problem localization and the validity of files, and ensures that the generated Core Dump files can be analyzed for problem localization.
Smart Images

Figure CN120909505A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more specifically, to a method, apparatus, computer device, and storage medium for generating files. Background Technology
[0002] When a process in the system exits abnormally (i.e., receives a specific signal), the process's memory information, register state, stack data, and other contents can be recorded in a binary file to generate a corresponding core dump file. This allows developers to analyze the core dump file and pinpoint the cause of the process exit.
[0003] Generally, due to limited device resources, such as the limited storage resources of embedded devices, it is necessary to limit the maximum size of the Core Dump file to avoid affecting the use of other functions. If the amount of data to be recorded in the Core Dump file exceeds the set maximum file size, the Core Dump file will be truncated when it is saved. The truncated Core Dump file only records part of the information when the process exited the context, and there may be cases where the stack information at the time of the exception is not saved, which may prevent the Core Dump file from being used for subsequent localization and analysis, affecting the accuracy of problem localization and analysis. Summary of the Invention
[0004] This disclosure provides at least one document generation method, apparatus, computer device, and storage medium.
[0005] In a first aspect, embodiments of this disclosure provide a file generation method, including:
[0006] When it is determined that a process needs to generate a corresponding core dump file, multiple virtual memory spaces in the process are traversed to determine the total amount of memory data that needs to be dumped in the process.
[0007] If it is determined that the total occupancy of the process is greater than the file size of the configured core transfer file, the occupancy of the first data to be transferred in the process is determined, wherein the first data to be transferred includes stack data in anonymous page memory data;
[0008] Based on the file size and the amount of memory occupied by the core transfer file, the memory usage allocated to the anonymous page memory data other than the stack data in the anonymous page memory data is determined, and a second transfer data matching the memory usage is determined from the other anonymous page memory data;
[0009] write the first to-be-converted data and the second to-be-converted data in the process into an initialization file to generate a target core conversion file corresponding to the process.
[0010] In an alternative implementation, the step of traversing the plurality of virtual memory spaces in the process to determine the total amount of memory data in the process that needs to be converted comprises:
[0011] For each of the virtual memory spaces, a storage space calculation function is used to determine a first data amount of memory data in the virtual memory space that needs to be converted;
[0012] According to the tag bit information of the virtual memory space, it is determined whether the virtual memory space is readable;
[0013] When the tag bit information indicates that the virtual memory space is not readable, the first data amount of the virtual memory space is adjusted to 0;
[0014] The first data amounts of the plurality of virtual memory spaces are summed to obtain the total amount of memory data in the process that needs to be converted.
[0015] In an alternative implementation, the step of determining the amount of first to-be-converted data in the process comprises:
[0016] For each of the virtual memory spaces, when it is determined that the virtual memory space is readable, it is determined whether the virtual memory space stores anonymous page memory data;
[0017] If yes, according to the address range information of the virtual memory space, it is determined whether the virtual memory space stores stack data;
[0018] If the virtual memory space stores stack data, it is determined that the virtual memory space belongs to stack memory;
[0019] The first data amounts of the virtual memory spaces belonging to the stack memory are summed to obtain the amount of first to-be-converted data in the process.
[0020] In an alternative implementation, the first to-be-converted data further comprises non-anonymous page memory data; and the step of determining the amount of first to-be-converted data in the process comprises:
[0021] For each of the virtual memory spaces, when it is determined that the virtual memory space is readable, it is determined whether the virtual memory space stores anonymous page memory data;
[0022] If yes, according to the address range information of the virtual memory space, it is determined whether the virtual memory space stores stack data;
[0023] if the data stored in the virtual memory space is not stack data, determining that the virtual memory space belongs to anonymous memory;
[0024] summing up a first data amount of the virtual memory space belonging to the anonymous memory to obtain a second data amount of other anonymous page memory data in the anonymous page memory data except the stack data;
[0025] determining an occupied amount of first to-be-swapped data in the process according to the total occupied amount and the second data amount.
[0026] In an optional implementation, the method further comprises:
[0027] obtaining stack address information of the process;
[0028] determining whether a memory start address indicated by the address range information of the virtual memory space is less than or equal to the stack address information and whether a memory end address indicated by the address range information of the virtual memory space is greater than the stack address information;
[0029] if yes, determining that the data stored in the virtual memory space is stack data;
[0030] if no, determining that the data stored in the virtual memory space is not stack data.
[0031] In an optional implementation, the method further comprises:
[0032] determining a target number of virtual memory spaces belonging to anonymous memory in the plurality of virtual memory spaces; wherein the virtual memory space belonging to anonymous memory refers to a readable virtual memory space storing other anonymous page memory data in the anonymous page memory data except the stack data;
[0033] the second to-be-swapped data matching the memory usage amount is determined from the other anonymous page memory data, comprising:
[0034] determining a data swapping amount allocated to each of the virtual memory spaces belonging to anonymous memory according to the target number and the memory usage amount;
[0035] selecting second to-be-swapped data matching the data swapping amount from each of the virtual memory spaces belonging to anonymous memory.
[0036] In an optional implementation, the method further comprises:
[0037] During running of the process, a target signal indicating generation of a core dump file is received;
[0038] In response to the target signal, it is determined whether there is core dump file generation configuration information;
[0039] If there is, it is determined that the process needs to generate a corresponding core dump file.
[0040] In a second aspect, the embodiments of the present disclosure further provide a file generation apparatus, comprising:
[0041] A first determination module is configured to, when it is determined that the process needs to generate a corresponding core dump file, traverse a plurality of virtual memory spaces in the process, and determine a total amount of memory data in the process that needs to be dumped;
[0042] A second determination module is configured to, when it is determined that the total amount of memory data in the process is greater than a file capacity of a configured core dump file, determine an amount of first data to be dumped in the process, wherein the first data to be dumped comprises stack data in anonymous page memory data;
[0043] A third determination module is configured to, according to the file capacity of the core dump file and the amount of data to be dumped, determine an amount of memory to be allocated for other anonymous page memory data in the anonymous page memory data except the stack data, and determine second data to be dumped from the other anonymous page memory data that matches the amount of memory;
[0044] A generation module is configured to write the first data to be dumped and the second data to be dumped in the process into an initialization file, and generate a target core dump file corresponding to the process.
[0045] In a possible implementation, when the first determination module traverses a plurality of virtual memory spaces in the process to determine a total amount of memory data in the process that needs to be dumped, the first determination module is configured to:
[0046] For each virtual memory space, a storage space calculation function is used to determine a first data amount of memory data in the virtual memory space that needs to be dumped;
[0047] According to tag bit information of the virtual memory space, it is determined whether the virtual memory space is readable;
[0048] When the tag bit information indicates that the virtual memory space is not readable, the first data amount of the virtual memory space is adjusted to 0;
[0049] The first data amounts of a plurality of virtual memory spaces are summed to obtain the total amount of memory data in the process that needs to be dumped.
[0050] In a possible implementation, the second determining module, when determining the first amount of data to be stored in the process, is configured to:
[0051] For each virtual memory space, when determining that the virtual memory space is readable, determine whether the virtual memory space stores anonymous page memory data;
[0052] If yes, determine, according to address range information of the virtual memory space, whether the virtual memory space stores stack data;
[0053] If the virtual memory space stores stack data, determine that the virtual memory space belongs to stack memory;
[0054] Sum a first data amount of the virtual memory space belonging to the stack memory to obtain the first amount of data to be stored in the process.
[0055] In a possible implementation, the second determining module, when the first amount of data to be stored further includes non-anonymous page memory data, and when determining the first amount of data to be stored in the process, is configured to:
[0056] For each virtual memory space, when determining that the virtual memory space is readable, determine whether the virtual memory space stores anonymous page memory data;
[0057] If yes, determine, according to address range information of the virtual memory space, whether the virtual memory space stores stack data;
[0058] If the virtual memory space does not store stack data, determine that the virtual memory space belongs to anonymous memory;
[0059] Sum a first data amount of the virtual memory space belonging to the stack memory to obtain the first amount of data to be stored in the process.
[0060] According to the total amount of occupation and the second data amount, determine the first amount of data to be stored in the process.
[0061] In a possible implementation, the second determining module, when determining, according to address range information of the virtual memory space, whether the virtual memory space stores stack data, is configured to:
[0062] Obtain stack address information of the process;
[0063] determining whether a memory start address indicated by address range information of the virtual memory space is less than or equal to the stack address information, and whether a memory end address indicated by the address range information is greater than the stack address information;
[0064] if yes, determining that the virtual memory space stores stack data;
[0065] if no, determining that the virtual memory space does not store stack data.
[0066] In a possible implementation, the third determining module is further configured to:
[0067] determining a target number of virtual memory spaces belonging to anonymous memory from the plurality of virtual memory spaces; wherein the virtual memory spaces belonging to anonymous memory refer to readable virtual memory spaces storing other anonymous page memory data in the anonymous page memory data except for the stack data;
[0068] When determining the second to-be-swapped data matching the memory usage from the other anonymous page memory data, the third determining module is configured to:
[0069] determining, according to the target number and the memory usage, a data swapping amount allocated to each of the virtual memory spaces belonging to anonymous memory;
[0070] selecting, from each of the virtual memory spaces belonging to anonymous memory, second to-be-swapped data matching the data swapping amount.
[0071] In a possible implementation, the first determining module, when determining that the process needs to generate a corresponding core swap file, is configured to:
[0072] receiving, during process running, a target signal indicating generation of a core swap file and sent by the process;
[0073] in response to the target signal, determining whether core swap file generation configuration information exists;
[0074] if yes, determining that the process needs to generate a corresponding core swap file.
[0075] In a third aspect, the present disclosure provides a computer device, a processor, and a memory. The memory stores machine readable instructions executable by the processor. The processor is configured to execute the machine readable instructions stored in the memory. When the machine readable instructions are executed by the processor, the steps of the first aspect or any possible implementation of the first aspect are performed.
[0076] In a fourth aspect, the optional implementation of the present disclosure further provides a computer readable storage medium, which stores a computer program. When the computer program is run, the steps of the first aspect or any possible implementation of the first aspect are performed.
[0077] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, but not limiting the technical solutions of the present disclosure.
[0078] The present disclosure provides a file generation method and device, computer equipment and a storage medium. The target core dump file generated in the present disclosure can ensure that the stack data in the process can be completely saved into the target Core Dump file, so that the generated target Core Dump file can be analyzed to perform the problem positioning process, thereby ensuring the effectiveness of the file. In addition, the present disclosure can also ensure that other anonymous page memory data other than the stack data can be retained to the greatest extent, thereby improving the accuracy of problem positioning.
[0079] In order to make the above-mentioned purposes, features and advantages of the present disclosure more obvious and easy to understand, the following preferred embodiments are specifically described below, and the accompanying drawings are described in detail as follows. BRIEF DESCRIPTION OF DRAWINGS
[0080] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following will briefly introduce the drawings needed to be used in the embodiments. The drawings herein are incorporated into the specification and form a part of the specification. These drawings show the embodiments consistent with the present disclosure, and are used to illustrate the technical solutions of the present disclosure together with the specification. It should be understood that the following drawings only show some embodiments of the present disclosure, and therefore should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can also be obtained without creative labor.
[0081] Figure 1 A flow chart of a file generation method provided by some embodiments of the present disclosure is shown;
[0082] Figure 2 A schematic diagram of memory data included in a process in a file generation method provided by some embodiments of the present disclosure is shown;
[0083] Figure 3 A flow chart of a file generation method provided by some embodiments of the present disclosure is shown;
[0084] Figure 4 A schematic diagram of a file generation device provided by some embodiments of the present disclosure is shown;
[0085] Figure 5A schematic diagram of a computer device is shown. DETAILED DESCRIPTION
[0086] To make the objectives, technical solutions and advantages of the embodiments of the present disclosure clearer, the following will be combined with the accompanying drawings for the embodiments of the present disclosure to make a clear and complete description of the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure and not all embodiments. The components of the embodiments of the present disclosure described and shown herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure is not intended to limit the scope of the claimed present disclosure, but only represents selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present disclosure.
[0087] Since the device has limited resources, such as an embedded device with relatively small storage resources, in order to avoid affecting the use of other functions, it is necessary to limit the maximum capacity of the Core Dump file. The capacity of the Core Dump file is related to the running process, and it is not a fixed value, so the file size cannot be determined in advance. If the maximum capacity of the Core Dump file is set too large, it is easy to fill the storage space of the device, and other business operations also need storage space, so it will affect the running of other businesses. If the maximum capacity of the Core Dump file is set too small, the content of the generated Core Dump file is not comprehensive, which may affect problem positioning.
[0088] Specifically, if the amount of data to be recorded by the Core Dump file is greater than the set maximum capacity of the Core Dump file, the Core Dump file will be truncated when it is retained. The truncated Core Dump file only records part of the information when the process exits the scene, and the stack information when the exception occurs is not saved, which makes it impossible to use the Core Dump file for positioning analysis later, affecting the accuracy of problem positioning analysis.
[0089] In the related art, for embedded devices, considering that the storage space is relatively limited, the storage space allocated to the Core Dump file is relatively small. Since the file size cannot be determined in advance, the generation of the Core Dump file may be disabled by default, or a smaller maximum capacity is set for the Core Dump file first, and if the generated file affects problem positioning, the maximum capacity of the file is modified to a larger value. However, the above process is relatively cumbersome, which makes the problem positioning efficiency low.
[0090] Based on the above research, the present disclosure provides a file generation method and device, computer equipment and storage medium. When it is determined that a process needs to generate a corresponding core dump file, the total amount of memory data that needs to be dumped in the process is determined by traversing a plurality of virtual memory spaces in the process. In the case where the total amount of memory in the process is greater than the file capacity of the configured core dump file, the amount of first data to be dumped in the process is determined, wherein the first data to be dumped includes stack data in anonymous page memory data. According to the file capacity of the core dump file and the amount of memory, the amount of memory allocated for other anonymous page memory data in addition to the stack data in the anonymous page memory data is determined, and the second data to be dumped that matches the amount of memory is determined from the other anonymous page memory data. The first data to be dumped and the second data to be dumped in the process are written into an initialization file to generate a target core dump file corresponding to the process. In the above process, it can be ensured that the stack data in the process can be completely saved to the target core dump file, so that the generated target core dump file can be analyzed to perform problem positioning process, and the effectiveness of the file is ensured. In addition, the present disclosure can also ensure that other anonymous page memory data in addition to the stack data can be retained to the greatest extent, thereby improving the accuracy of problem positioning.
[0091] For the above, the inventors have come to the conclusion after careful research and practice, so the discovery process of the above problems and the solutions proposed by the present disclosure to solve the above problems are the contributions of the inventors to the present disclosure.
[0092] It should be noted that similar reference numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0093] In order to facilitate the understanding of the technical solutions of the present disclosure, first, the technical terms in the embodiments of the present disclosure are explained:
[0094] The Executable and Linkable Format (ELF) file is a standard file format for executable files, object files and shared libraries. It is a universal binary file format used to represent executable programs and related information in various operating systems and architectures. The ELF file includes the code, data, resources and information for loading and executing the program of the program. The ELF file has portability because it defines the standard for execution on different systems, including file header, segment header, section header and other structures. ELF format is commonly used in UNIX-like systems such as Linux and BSD.
[0095] The core dump file is essentially an ELF file format. In an operating system, when a process exits due to an abnormal reason (i.e., receiving a specific signal), the memory information, register state, stack data and the like of the process can be recorded in a binary file to generate a corresponding core dump file, so that subsequent developers can analyze the core dump file to locate the reason for the process exit.
[0096] To facilitate the understanding of the present embodiment, first, a file generation method disclosed by the present embodiment is introduced in detail. The execution subject of the file generation method provided by the present embodiment is generally a computer device with certain computing power, which may, for example, include a terminal device or a server or other processing device. The terminal device may be a user equipment (UE), a mobile device, a user terminal, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, an embedded device, etc. In some possible implementation manners, the file generation method can be realized by a processor calling computer readable instructions stored in a memory.
[0097] Referring to FIG. 1, Figure 1 The method includes steps S101-S104, wherein:
[0098] S101, when it is determined that a process needs to generate a corresponding core dump file, a plurality of virtual memory spaces in the process are traversed to determine the total amount of memory data that needs to be dumped in the process.
[0099] In an operating system, when a process runs into a fault, such as finding that the process performs an incorrect memory operation (for example, accessing illegal memory, repeatedly releasing memory, etc.) during running, the process sends a specific signal to itself, so that the process generates a corresponding core dump file and exits.
[0100] For example, when a specific signal is detected in a process, it is determined that the process needs to generate a corresponding core dump file. Alternatively, when a specific signal is detected in a process, it is determined whether the core file switch of the process is in a disabled state. If the core file switch is in the disabled state, the core dump file is not generated. Otherwise, if the core file switch is not in the disabled state, it is determined that the process needs to generate a corresponding core dump file.
[0101] In an alternative implementation, determining that the process needs to generate the corresponding core dump file comprises: receiving a target signal issued by the process during the running of the process, the target signal being used to indicate generation of the core dump file; and in response to the target signal, determining whether the core dump file generation configuration information exists; and if the core dump file generation configuration information exists, determining that the process needs to generate the corresponding core dump file.
[0102] In an alternative implementation, the target signal is received by the process during the running of the process, and the specific information of the target signal can be set according to actual conditions, which is not limited herein.
[0103] The core dump file generation configuration information includes, but is not limited to, a file path, a file name, a file naming format, a file capacity, and the like. In response to the target signal, if it is determined that the core dump file generation configuration information exists, it is determined that the process needs to generate the corresponding core dump file. If it is determined that the core dump file generation configuration information does not exist, it is determined that the core dump file does not need to be generated. Through the above process, it can be determined more accurately and conveniently whether the process needs to generate the core dump file.
[0104] When it is determined that the process needs to generate the corresponding core dump file, a plurality of virtual memory spaces (VMA) in the process are traversed to determine the total amount of memory data that needs to be dumped in the process. For example, in an implementation, each virtual memory space in the process is traversed to determine the memory data that needs to be dumped in the virtual memory space and to determine the amount of data of the memory data. The amounts of data of the memory data that needs to be dumped in the plurality of virtual memory spaces are summed up to obtain the total amount of memory data that needs to be dumped in the process.
[0105] Generally, the process needs memory resources when running, and the mmap field of the mm_struct structure on the process structure is a vm_area_struct (vma for short) structure. The memory applied for by the process is organized through the vm_area_struct structure, and the plurality of memories applied for by the process are connected through a chain table by the vma. Referring to a process memory data schematic diagram shown in FIG. 1, Figure 2 which is only a simple schematic diagram, and the specific content is determined according to actual conditions. Figure 2
[0106] Each VMA corresponds to a vm_area_struct structure, and there are multiple vma structures in a process, that is, there is a vma linked list in the process, and different vma structures correspond to different contents. For example, some vmas correspond to files, some vmas correspond to dynamically allocated heap memory, and some vmas correspond to stack memory, etc. In the vma, the memory start address vm_start, the memory end address vm_end, the memory flag vm_flags, and the read, write, executable, and other information marked on the memory flag vm_flags are recorded. In implementation, the total amount of memory data to be stored in the process and the amount of first data to be stored can be determined by traversing the vma linked list of the process.
[0107] In an optional implementation, the total amount of memory data to be stored in the process is determined by traversing multiple virtual memory spaces in the process, including:
[0108] Step a1, for each virtual memory space, a storage space calculation function is used to determine the first data amount of the memory data to be stored in the virtual memory space.
[0109] Step a2, according to the flag information of the virtual memory space, it is determined whether the virtual memory space is readable.
[0110] Step a3, when the flag information indicates that the virtual memory space is not readable, the first data amount of the virtual memory space is adjusted to 0.
[0111] Step a4, the first data amounts of the multiple virtual memory spaces are summed to obtain the total amount of memory data to be stored in the process.
[0112] In implementation, for each virtual memory space, a storage space calculation function such as the vma_dump_size function is used to determine the first data amount of the memory data to be stored in the virtual memory space.
[0113] Considering that the content stored in the unreadable virtual memory space may not be executed, that is, the data in the virtual memory space does not need to be stored, the flag information (such as the memory flag vm_flags) of the virtual memory space can be used to determine whether the virtual memory space is readable.
[0114] When it is determined that the virtual memory space is not readable, the first data amount of the virtual memory space is adjusted to 0, and the first data amounts of the multiple virtual memory spaces are summed to obtain the total amount of memory data to be stored in the process. Alternatively, when it is determined that the virtual memory space is not readable, the first data amount of the file is not counted, that is, the sum of the first data amounts of the readable virtual memory spaces is determined to obtain the total amount of memory data to be stored in the process.
[0115] By determining whether the virtual memory space is readable, a first amount of readable virtual memory space is counted to more accurately determine the total amount of memory data in the process that needs to be stored.
[0116] After determining the total amount of memory data in the process that needs to be stored, it is determined whether the total amount is greater than the file capacity of the configured core dump file. The file capacity of the Core Dump file can be determined according to the performance of the device. For example, if the device has good performance (such as large disk space and fast processing speed), a larger file capacity can be set, and vice versa. If the device has poor performance, a smaller file capacity can be set. After determining the file capacity, the file capacity of the Core Dump file can be configured in the operating system before running.
[0117] If it is determined that the total amount is less than or equal to the file capacity of the configured core dump file, the Core Dump file can store all the memory data in the process that needs to be stored without truncation, so the memory data in the process that needs to be stored is directly stored in the initialization file to generate the target Core Dump file corresponding to the process.
[0118] If it is determined that the total amount is greater than the file capacity of the configured core dump file, the Core Dump file cannot store all the memory data in the process that needs to be stored, and part of the data needs to be stored.
[0119] Specifically, after S101, it further includes: S102, in a case where the total amount corresponding to the process is greater than the file capacity of the configured core dump file, determining the amount of first to-be-stored data in the process, wherein the first to-be-stored data includes stack data in the anonymous page memory data.
[0120] In a case where the total amount corresponding to the process is greater than the file capacity of the configured core dump file, the amount of first to-be-stored data in the process is determined, wherein the first to-be-stored data includes stack data in the anonymous page memory data. For example, stack data can be selected from the plurality of readable virtual memory spaces, and the amount of stack data is counted to obtain the amount of first to-be-stored data in the process.
[0121] In specific implementation, considering that the non-anonymous page memory data is relatively small, in order to more accurately locate the problem, the first to-be-stored data can also include non-anonymous page memory data. That is, the first to-be-stored data can include stack data, or the first to-be-stored data can include stack data and non-anonymous page memory data.
[0122] In one optional implementation, when the first data to be transferred includes stack data, determining the amount of the first data to be transferred occupied in the process includes:
[0123] Step b1: For each virtual memory space, when it is determined that the virtual memory space is readable, determine whether the virtual memory space stores anonymous page memory data;
[0124] Step b2: If yes, then determine whether the data stored in the virtual memory space is stack data based on the address range information of the virtual memory space.
[0125] Step b3: If the virtual memory space stores stack data, then the virtual memory space is determined to belong to stack memory;
[0126] Step b4: Sum the first amount of data belonging to the virtual memory space of the stack memory to obtain the amount of the first data to be transferred in the process.
[0127] For each virtual memory space, once it is determined that the virtual memory space is readable, it is determined whether the virtual memory space stores anonymous page memory data based on the content information stored in the virtual memory space. If not, no further processing is required.
[0128] If the virtual memory space stores anonymous page memory data, then the address range information of the virtual memory space is used to determine whether the data stored in the virtual memory space is stack data. For example, it is determined whether the address range corresponding to the virtual memory space includes the process stack address; if it does, then the virtual memory space stores stack data.
[0129] If the virtual memory space does not store stack data, there is no need to perform data usage statistics. If the virtual memory space stores stack data, then the virtual memory space is determined to belong to the stack memory, and the first data volume of the virtual memory space belonging to the stack memory is summed to obtain the usage of the first data to be transferred in the process.
[0130] By traversing the readable virtual memory space, the virtual memory space storing stack data is identified, enabling the search for stack data and the statistics of stack data usage. This allows for the determination of the usage of the first piece of data to be dumped in the process, which can then be used to allocate memory for the Core Dump file. Furthermore, by searching for stack data, the subsequent dumping of stack data can be performed more efficiently to generate the target Core Dump file.
[0131] In another optional implementation, when the first data to be transferred includes stack data and non-anonymous page memory data, determining the amount of the first data to be transferred in the process includes:
[0132] Step c1, for each virtual memory space, when it is determined that the virtual memory space is readable, it is determined whether the virtual memory space stores anonymous page memory data;
[0133] Step c2, if yes, according to the address range information of the virtual memory space, it is determined whether the virtual memory space stores stack data;
[0134] Step c3, if the virtual memory space does not store stack data, it is determined that the virtual memory space belongs to anonymous memory;
[0135] Step c4, sum the first data amount of the virtual memory space belonging to the anonymous memory, to obtain the second data amount of the other anonymous page memory data in the anonymous page memory data except the stack data;
[0136] Step c5, according to the total occupation amount and the second data amount, the occupation amount of the first to-be-swapped data in the process is determined.
[0137] When the first to-be-swapped data includes stack data and non-anonymous page memory data, since the stack data belongs to the anonymous page memory data, and the stack data is relatively important data, in order to realize the screening of the stack data and the statistics of the data amount of the first to-be-swapped data, the disclosure indirectly obtains the occupation amount of the first to-be-swapped data by statistics of the second data amount of the other anonymous page memory data in the anonymous page memory data except the stack data. At the same time, the screening of the non-anonymous page memory data, the stack data in the anonymous page memory data and the other anonymous page memory data is realized in this process, so that the subsequent data swapping can be more efficient.
[0138] In implementation, for each virtual memory space, when it is determined that the virtual memory space is readable, according to the content information stored in the virtual memory space, it is determined whether the virtual memory space stores anonymous page memory data. If not, no data amount statistics is performed.
[0139] If the virtual memory space stores anonymous page memory data, according to the address range information of the virtual memory space, it is determined whether the virtual memory space stores stack data. If the virtual memory space does not store stack data, it is determined that the virtual memory space belongs to anonymous memory, that is, the virtual memory space belonging to the anonymous memory refers to the readable virtual memory space storing the other anonymous page memory data in the anonymous page memory data except the stack data. When the virtual memory space stores stack data, no data amount statistics is performed.
[0140] Sum the first data amount of the virtual memory space belonging to the anonymous memory in the plurality of virtual memory spaces to obtain a second data amount of the other anonymous page memory data in the anonymous page memory data except the stack data. Then, subtract the total occupation amount from the second data amount to obtain the occupation amount of the first to-be-converted data in the process.
[0141] By traversing the readable virtual memory space, the second data amount of the other anonymous page memory data in the anonymous page memory data except the stack data is determined to determine the first data amount according to the second data amount of the other anonymous page memory data and the total occupation amount, so as to realize the statistics of the occupation amount of the first to-be-converted data, so that the memory allocation of the Core Dump file can be performed according to the occupation amount of the first to-be-converted data subsequently. Meanwhile, by screening the stack data, the conversion of the stack data, the non-anonymous page memory data and the other anonymous page memory data can be performed more efficiently subsequently to generate the target Core Dump file.
[0142] The following specifically describes the process of determining whether the stack data is stored in the virtual memory space according to the address range information of the virtual memory space.
[0143] Specifically, the following steps are included: obtaining the stack address information of the process; determining whether the memory start address indicated by the address range information of the virtual memory space is less than or equal to the stack address information and whether the memory end address indicated by the address range information of the virtual memory space is greater than the stack address information; if yes, it is determined that the stack data is stored in the virtual memory space; if no, it is determined that the stack data is not stored in the virtual memory space.
[0144] In implementation, the start_stack field on the mm_struct can be obtained, which records the stack address information of the process stack. Then, it is determined whether the following condition is met: vma start address (i.e. memory start address) ≤ start_stack < vma end address (i.e. memory end address). If yes, it is determined that the stack data is stored in the virtual memory space; otherwise, if no, it is determined that the stack data is not stored in the virtual memory space.
[0145] After S102, it further includes: S103, determining the memory usage amount allocated for the other anonymous page memory data except the stack data in the anonymous page memory data according to the file capacity of the core conversion file and the occupation amount, and determining the second to-be-converted data matching the memory usage amount from the other anonymous page memory data.
[0146] After the occupation amount of the first to-be-converted data in the process is determined, the file capacity of the core conversion file can be subtracted from the occupation amount of the first to-be-converted data, to obtain the memory usage amount allocated to the other anonymous page memory data in the anonymous page memory data except for the stack data. Then, the second to-be-converted data matching the memory usage amount is determined from the other anonymous page memory data, that is, the second to-be-converted data matching the memory usage amount is determined. For example, the second to-be-converted data can be randomly selected from the other anonymous page memory data.
[0147] In order to guarantee the accuracy and comprehensiveness of the generated target Core Dump file, and guarantee the success of problem positioning, in the disclosure, the second to-be-converted data can be selected from each virtual memory space belonging to anonymous memory, to realize the screening and conversion of data.
[0148] In an optional implementation, the method further includes: determining a target number of virtual memory spaces belonging to anonymous memory in the plurality of virtual memory spaces; wherein the virtual memory space belonging to anonymous memory refers to a readable virtual memory space storing other anonymous page memory data in the anonymous page memory data except for the stack data.
[0149] The second to-be-converted data matching the memory usage amount is determined from the other anonymous page memory data, including: determining the data conversion amount allocated to each virtual memory space belonging to anonymous memory according to the target number and the memory usage amount; and selecting the second to-be-converted data matching the data conversion amount from each virtual memory space belonging to anonymous memory.
[0150] In implementation, when the occupation amount of the first to-be-converted data is determined, the target number of virtual memory spaces belonging to anonymous memory can be synchronously counted. That is, the target number of virtual memory spaces belonging to anonymous memory can be counted from the plurality of readable virtual memory spaces, and the virtual memory space belonging to anonymous memory refers to a readable virtual memory space storing other anonymous page memory data in the anonymous page memory data except for the stack data.
[0151] After the target number is determined, the memory usage amount allocated to the other anonymous page memory data is divided by the target number, to obtain the data conversion amount allocated to each virtual memory space belonging to anonymous memory. Then, the second to-be-converted data matching the data conversion amount is selected from each virtual memory space belonging to anonymous memory, for example, the second to-be-converted data matching the data conversion amount can be selected from a preset starting position of the virtual memory space belonging to anonymous memory; the preset starting position can be, for example, a beginning, an end or an intermediate position of the virtual memory space belonging to anonymous memory, and the like.
[0152] Through the above process, the second to-be-stored data can be selected from the virtual memory space belonging to the anonymous memory, and the data can be comprehensively screened and stored, so as to ensure the success rate of problem positioning.
[0153] After S103, the method further includes: S104, writing the first to-be-stored data and the second to-be-stored data in the process into an initialization file to generate a target core dump file corresponding to the process.
[0154] In implementation, the first to-be-stored data and the second to-be-stored data in the process can be written into the initialization file according to the format requirement of the Core Dump file to generate the target core dump file corresponding to the process.
[0155] Further, the generated target core dump file can be named and saved according to the core dump file generation configuration information.
[0156] The file generation method of the present disclosure is exemplarily described below by taking the first to-be-stored data including the stack data and the non-anonymous page memory data as an example, referring to FIG. 1. Figure 3 The method includes:
[0157] S301, generating and sending a target signal when the process is abnormal.
[0158] The target signal can be used to instruct to generate a core dump file.
[0159] S302, determining whether there is core dump file generation configuration information in response to the target signal.
[0160] S303, if there is, determining that the process needs to generate a corresponding Core Dump file.
[0161] On the contrary, if there is not, determining that the process does not need to generate a corresponding Core Dump file.
[0162] S304, traversing a vma linked list in the process; for each vma, the following process is executed:
[0163] 1. calculating a first data amount of the memory data to be saved in the vma by using a vma_dump_size function;
[0164] 2. checking a flag bit of the vma to determine whether the vma is readable; if the vma is readable, step 3 is executed; if the vma is not readable, the first data amount of the vma is adjusted to 0;
[0165] 3. checking whether the vma memory is anonymous page memory; if the vma memory is anonymous page memory, obtaining a start_stack field on a mm_struct, and determining whether the vma is stack memory according to a process address range of the vma.
[0166] That is, determine whether the anonymous page memory data stored in the vma. And determine whether the vma stores stack data.
[0167] S305, sum the first data amount of multiple vmas, to get the total occupation amount of memory data in the process that needs to be transferred.
[0168] S306, determine whether the total occupation amount corresponding to the process is greater than the file capacity of the Core Dump file.
[0169] S307, if the total occupation amount corresponding to the process is less than or equal to the file capacity of the Core Dump file, the memory data in the process that needs to be transferred is saved completely to generate the target Core Dump file corresponding to the process.
[0170] S308, if the total occupation amount corresponding to the process is greater than the file capacity of the Core Dump file, the memory data in the process that needs to be transferred cannot be saved completely and needs to be truncated.
[0171] S309, calculate the second data amount of other anonymous page memory in the anonymous page memory except the stack memory; subtract the total occupation amount from the second data amount to get the occupation amount corresponding to the stack memory and the non-anonymous page memory.
[0172] That is, calculate the second data amount of other anonymous page memory data in the anonymous page memory data except the stack data; and the occupation amount of the first data to be transferred.
[0173] S310, determine the number of vmas in multiple vmas that belong to other anonymous page memory except the stack memory; and subtract the occupation amount corresponding to the stack memory and the non-anonymous page memory from the file capacity of the Core Dump file to get the memory usage of other anonymous page memory in the anonymous page memory except the stack memory. Divide the memory usage of other anonymous page memory by the number of vmas of other anonymous page memory to get the data transfer amount allocated to each other anonymous page memory.
[0174] S311, traverse the vma chain table in the process, and select other anonymous data (i.e. second data to be transferred) of the data transfer amount from each other anonymous page memory vma. Write the stack data, non-anonymous page data, and selected other anonymous data into the initialization file according to the format requirements of the Core Dump file to generate the target Core Dump file corresponding to the process.
[0175] The present disclosure determines whether the generated Core Dump file exceeds the maximum size of the set Core Dump file when the process is abnormal and it is determined that the Core Dump file needs to be generated, and if it exceeds, a truncated Core Dump file is generated, and the complete stack information is stored in the truncated Core Dump file, and the other anonymous page memory data in the anonymous page memory data except the stack data is maximally retained, thereby alleviating the problem that when the storage space of the device is small, the generated Core Dump file cannot be analyzed and problem positioning cannot be performed.
[0176] Those skilled in the art can understand that the writing order of each step in the above method of the specific embodiment does not mean a strict execution order and does not constitute any limitation on the implementation process, and the specific execution order of each step should be determined by its function and possible inherent logic.
[0177] Based on the same inventive concept, the present disclosure also provides a file generation device corresponding to the file generation method. Since the principle of solving the problem of the device in the present disclosure is similar to the above-mentioned file generation method of the present disclosure, the implementation of the device can be referred to the implementation of the method, and the repeated parts will not be described.
[0178] Referring to Figure 4 Fig. 1 shows a schematic diagram of a file generation device provided by an embodiment of the present disclosure. The device comprises a first determination module 401, a second determination module 402, a third determination module 403, and a generation module 404.
[0179] The first determination module 401 is configured to, when it is determined that a process needs to generate a corresponding core dump file, traverse a plurality of virtual memory spaces in the process, and determine a total occupation amount of memory data in the process that needs to be dumped.
[0180] The second determination module 402 is configured to, when it is determined that the total occupation amount of the process corresponding to the process is greater than the file capacity of the configured core dump file, determine the occupation amount of first to-be-dumped data in the process, wherein the first to-be-dumped data comprises stack data in anonymous page memory data.
[0181] The third determination module 403 is configured to determine, according to the file capacity of the core dump file and the occupation amount, a memory usage amount allocated to other anonymous page memory data in the anonymous page memory data except the stack data, and determine second to-be-dumped data matching the memory usage amount from the other anonymous page memory data.
[0182] The generation module 404 is configured to write the first to-be-dumped data and the second to-be-dumped data in the process into an initialization file, and generate a target core dump file corresponding to the process.
[0183] In a possible implementation, the first determining module 401, when determining the total amount of memory data to be migrated in the process by traversing the plurality of virtual memory spaces in the process, is configured to:
[0184] for each of the virtual memory spaces, determine a first data amount of memory data to be migrated in the virtual memory space by using a storage space calculation function;
[0185] determine whether the virtual memory space is readable according to tag bit information stored in the virtual memory space;
[0186] when the tag bit information indicates that the virtual memory space is not readable, adjust the first data amount of the virtual memory space to 0;
[0187] sum the first data amounts of the plurality of virtual memory spaces to obtain the total amount of memory data to be migrated in the process.
[0188] In a possible implementation, the second determining module 402, when determining the amount of first data to be migrated in the process, is configured to:
[0189] for each of the virtual memory spaces, when it is determined that the virtual memory space is readable, determine whether the virtual memory space stores anonymous page memory data;
[0190] if yes, determine whether the virtual memory space stores stack data according to address range information of the virtual memory space;
[0191] if the virtual memory space stores stack data, it is determined that the virtual memory space belongs to stack memory;
[0192] sum the first data amounts of the virtual memory spaces belonging to the stack memory to obtain the amount of first data to be migrated in the process.
[0193] In a possible implementation, the second determining module 402, when the first data to be migrated further includes non-anonymous page memory data, is configured to, when determining the amount of first data to be migrated in the process:
[0194] for each of the virtual memory spaces, when it is determined that the virtual memory space is readable, determine whether the virtual memory space stores anonymous page memory data;
[0195] if yes, determine whether the virtual memory space stores stack data according to address range information of the virtual memory space;
[0196] if the stack data is stored in the virtual memory space, determining that the virtual memory space belongs to the anonymous memory;
[0197] summing up a first data amount of the virtual memory space belonging to the anonymous memory to obtain a second data amount of the other anonymous page memory data in the anonymous page memory data except the stack data;
[0198] determining the occupation amount of the first to-be-swapped data in the process according to the total occupation amount and the second data amount.
[0199] In a possible implementation, the second determining module 402, when determining whether the stack data is stored in the virtual memory space according to the address range information of the virtual memory space, is configured to:
[0200] obtain the stack address information of the process;
[0201] determine whether a memory start address indicated by the address range information of the virtual memory space is less than or equal to the stack address information and whether a memory end address indicated by the address range information of the virtual memory space is greater than the stack address information;
[0202] if yes, it is determined that the stack data is stored in the virtual memory space;
[0203] if no, it is determined that the stack data is not stored in the virtual memory space.
[0204] In a possible implementation, the third determining module 403 is further configured to:
[0205] determine a target number of virtual memory spaces belonging to the anonymous memory in the plurality of virtual memory spaces; wherein the virtual memory space belonging to the anonymous memory refers to a readable virtual memory space storing the other anonymous page memory data in the anonymous page memory data except the stack data;
[0206] The third determining module 403, when determining the second to-be-swapped data matching the memory usage from the other anonymous page memory data, is configured to:
[0207] determine, according to the target number and the memory usage, a data swapping amount allocated to each of the virtual memory spaces belonging to the anonymous memory;
[0208] select the second to-be-swapped data matching the data swapping amount from each of the virtual memory spaces belonging to the anonymous memory.
[0209] In a possible implementation, the first determining module 401, when determining that the process needs to generate the corresponding core swapping file, is configured to:
[0210] During running of the process, a target signal indicating generation of a core dump file is received;
[0211] In response to the target signal, it is determined whether there is core dump file generation configuration information;
[0212] If there is, it is determined that the process needs to generate a corresponding core dump file.
[0213] The description of the processing flow of each module in the device and the interaction flow between the modules can refer to the related description in the above method embodiments, and will not be described in detail here.
[0214] The present disclosure also provides a computer device, as shown in Figure 5 The computer device structure schematic diagram provided by the present disclosure includes:
[0215] a processor 51 and a memory 52; the memory 52 stores machine readable instructions executable by the processor 51, and the processor 51 is configured to execute the machine readable instructions stored in the memory 52, and when the machine readable instructions are executed by the processor 51, the processor 51 executes the following steps:
[0216] When it is determined that the process needs to generate a corresponding core dump file, the total amount of memory data to be dumped in the process is determined by traversing a plurality of virtual memory spaces in the process;
[0217] When it is determined that the total amount of the process corresponding to the total amount is greater than the file capacity of the configured core dump file, the amount of occupation of first to-be-dumped data in the process is determined, wherein the first to-be-dumped data includes stack data in anonymous page memory data;
[0218] According to the file capacity of the core dump file and the amount of occupation, the amount of memory usage allocated to other anonymous page memory data in the anonymous page memory data except the stack data is determined, and second to-be-dumped data matching the amount of memory usage is determined from the other anonymous page memory data;
[0219] The first to-be-dumped data and the second to-be-dumped data in the process are written into an initialization file to generate a target core dump file corresponding to the process.
[0220] The above memory 52 includes a memory 521 and an external memory 522; the memory 521 here is also called an internal memory, used for temporarily storing operation data in the processor 51 and exchanging data with the external memory 522 such as a hard disk, and the processor 51 exchanges data with the external memory 522 through the memory 521.
[0221] The specific execution process of the above instructions can refer to the steps of the file generation method described in the embodiments of the present disclosure, which will not be repeated here.
[0222] The embodiments of the present disclosure also provide a computer readable storage medium, which stores a computer program. When the computer program is run by a processor, the steps of the file generation method described in the above method embodiments are executed. The storage medium can be a volatile or non-volatile computer readable storage medium.
[0223] The embodiments of the present disclosure also provide a computer program product carrying a program code. The instructions included in the program code can be used to execute the steps of the file generation method described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0224] The computer program product can be specifically implemented by hardware, software or a combination thereof. In an optional embodiment, the computer program product is specifically embodied as a computer storage medium. In another optional embodiment, the computer program product is specifically embodied as a software product, such as a software development kit (SDK) and the like.
[0225] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system and device can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here. In several embodiments provided by the present disclosure, it can be understood that the disclosed system, device and method can be implemented by other ways. The above-described device embodiments are only schematic, for example, the division of the units is only a logical function division, and actual implementation can be another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some communication interface, device or unit, which can be electrical, mechanical or other forms.
[0226] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or they can be distributed on multiple network units. According to actual needs, some or all of the units can be selected to achieve the purpose of the present embodiment.
[0227] In addition, each function unit in various embodiments of the present disclosure can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit.
[0228] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a nonvolatile computer readable storage medium executable by a processor. Based on this understanding, the technical solutions of the present disclosure essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0229] Finally, it should be noted that: the above-described embodiments are merely specific embodiments of the present disclosure, used to illustrate the technical solutions of the present disclosure, rather than limit them. The protection scope of the present disclosure is not limited thereto, although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand: any skilled person familiar with the technical field of the present disclosure can modify or easily think of changes to the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some technical features; and these modifications, changes or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be covered within the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.
Claims
1. A file generation method characterized by, The method comprises the following steps: when it is determined that a process needs to generate a corresponding core dump file, a total amount of memory data needing to be dumped in the process is determined by traversing a plurality of virtual memory spaces in the process; when it is determined that the total amount of memory data needing to be dumped in the process is greater than a file capacity of a configured core dump file, an amount of data needing to be dumped in the process is determined, wherein the data needing to be dumped comprises stack data in anonymous page memory data; an amount of memory usage allocated to other anonymous page memory data except the stack data in the anonymous page memory data is determined according to the file capacity of the core dump file and the amount of data needing to be dumped, and second data needing to be dumped is determined from the other anonymous page memory data; the first data needing to be dumped and the second data needing to be dumped in the process are written into an initialization file to generate a target core dump file corresponding to the process.
2. The method of claim 1, wherein, The step of determining the total amount of memory data needing to be dumped in the process by traversing the plurality of virtual memory spaces in the process comprises the following steps: for each virtual memory space, a first amount of data needing to be dumped in the virtual memory space is determined by using a storage space calculation function; whether the virtual memory space is readable is determined according to tag bit information of the virtual memory space; when the tag bit information indicates that the virtual memory space is not readable, the first amount of data of the virtual memory space is adjusted to 0; the first amounts of data of the plurality of virtual memory spaces are summed to obtain the total amount of memory data needing to be dumped in the process.
3. The method of claim 2, wherein, The step of determining the amount of data needing to be dumped in the process comprises the following steps: for each virtual memory space, when it is determined that the virtual memory space is readable, whether the virtual memory space stores anonymous page memory data is determined; if yes, whether the virtual memory space stores stack data is determined according to address range information of the virtual memory space; if the virtual memory space stores stack data, it is determined that the virtual memory space belongs to stack memory; the first amounts of data of the virtual memory spaces belonging to the stack memory are summed to obtain the amount of data needing to be dumped in the process.
4. The method of claim 2, wherein, The first data needing to be dumped also comprises non-anonymous page memory data; the step of determining the amount of data needing to be dumped in the process comprises the following steps: for each virtual memory space, when it is determined that the virtual memory space is readable, whether the virtual memory space stores anonymous page memory data is determined; if yes, whether the virtual memory space stores stack data is determined according to address range information of the virtual memory space; if the virtual memory space does not store stack data, it is determined that the virtual memory space belongs to anonymous memory; a second amount of data of other anonymous page memory data except the stack data in the anonymous page memory data is obtained by summing the first amounts of data of the virtual memory spaces belonging to the anonymous memory; the amount of data needing to be dumped in the process is determined according to the total amount and the second amount of data.
5. The method of claim 3, wherein, The method further comprises: determining a target number of virtual memory spaces belonging to anonymous memory in the plurality of virtual memory spaces; wherein the virtual memory spaces belonging to anonymous memory refer to readable virtual memory spaces storing other anonymous page memory data in the anonymous page memory data except the stack data; the determining of the second to-be-swapped data matching the memory usage from the other anonymous page memory data comprises: determining, according to the target number and the memory usage, a data-swapping amount allocated to each of the virtual memory spaces belonging to anonymous memory; selecting, from each of the virtual memory spaces belonging to anonymous memory, second to-be-swapped data matching the data-swapping amount.
6. The method according to any one of claims 1 to 5, characterized in that, The determining of the process requiring to generate a corresponding core-swapped file comprises: receiving, during process running, a target signal indicating generation of a core-swapped file sent by the process; in response to the target signal, determining whether there is core-swapped file generation configuration information; if there is, determining that the process requires to generate a corresponding core-swapped file. The method comprises:
7. The method of claim 1, wherein, a first determining module configured to, when determining that a process requires to generate a corresponding core-swapped file, traverse a plurality of virtual memory spaces in the process, and determine a total occupied amount of memory data in the process requiring to be swapped; a second determining module configured to, when determining that the total occupied amount of the process corresponding to the process is greater than a file capacity of a configured core-swapped file, determine an occupied amount of first to-be-swapped data in the process, wherein the first to-be-swapped data comprises stack data in anonymous page memory data; a third determining module configured to, according to the file capacity of the core-swapped file and the occupied amount, determine a memory usage allocated to other anonymous page memory data in the anonymous page memory data except the stack data, and determine second to-be-swapped data matching the memory usage from the other anonymous page memory data; a generating module configured to write the first to-be-swapped data and the second to-be-swapped data in the process into an initialization file, and generate a target core-swapped file corresponding to the process.
8. A file generating apparatus characterized by comprising: The method comprises: a processor and a memory, the memory storing machine-readable instructions executable by the processor, the processor being configured to execute the machine-readable instructions stored in the memory, and the machine-readable instructions being configured to cause the processor to perform the steps of the file generation method according to any one of claims 1 to 7 when executed by the processor. 9. A computer device, comprising: 10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is run by a computer device, and the computer device executes the steps of the file generation method in any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for generating core compressed file
CN114968632A
Core dump file generation method and device, electronic equipment and storage medium
CN115391077A
Method and device for generating core transfer file
CN118733319A
Enhanced restart of a core dumping application
US20160154701A1