A method for generating a core dump file, a computing device, and a storage medium

By preloading the library to monitor the target program to generate new processes and obtain related data, the problem of large core dump files generated by the Linux kernel is solved, and small and confidential core dump files can be generated in user mode, reducing the impact on system performance.

CN114138531BActive Publication Date: 2025-09-23UNIONTECH SOFTWARE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111460118.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-23
Publication Date
2025-09-23
Estimated Expiration
2041-09-23

AI Technical Summary

Technical Problem

The core dump files generated by the existing Linux kernel are too large, affecting system performance and requiring root privilege configuration, which impairs system stability.

Method used

The status of the target program is monitored by the preloading library, a new process is generated and the associated data is obtained. The core dump file is generated using the signal processing function and the data capture function. Part of the data in the file is compressed to generate a core dump file in a custom format.

Benefits of technology

Generate core dump files in user mode without root privileges, reduce file size, minimize impact on system performance, and maintain a certain degree of confidentiality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114138531B_ABST
    Figure CN114138531B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, computing device, and storage medium for generating a core dump file. The method comprises: monitoring the status of a target program, wherein the target program has a preload library embedded therein; if an exception occurs in the target program, copying the current process of the target program to generate a new process corresponding to the current process; obtaining associated data of the current process based on the new process; and dumping the associated data to generate a core dump file. According to the technical solution of the present invention, a lightweight core dump file with a certain degree of confidentiality can be generated without root privileges.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the invention patent application filed on September 23, 2021. The application number of the original application is: 2021111117678, and the name of the invention is: A method for generating a core dump file, a computing device and a storage medium. Technical Field

[0002] The present invention relates to the field of computer technology, and in particular to a method for generating a core dump file, a computing device, and a storage medium. Background Art

[0003] A core dump is a file in which the operating system stores the current state of a program when a program fails and terminates abnormally. Typically, a core dump file contains information about the program's runtime memory, register status, stack pointer, and memory management.

[0004] Taking the Linux operating system as an example, when a core dump file is generated in kernel mode, the entire effective VMA (Virtual Memory Areas) information of the process must be dumped. This means that the core dump file of a large process will be very large, even reaching the TB (Terabyte) level. The generation and storage process seriously consumes various system resources and has an impact on system stability.

[0005] Currently, new versions of the Linux kernel provide a virtual configuration file to control the size of core dump files. Essentially, this configuration file categorizes the dumped memory, marking each category with a bit. For example, if you set up a core dump file with root privileges, open Google Chrome and visit the Baidu homepage, then force quit the Google Chrome process, you can generate a core dump file as large as 350MB (megabytes). This suggests that while the Linux kernel provides a core dump mechanism, it requires root privileges to configure and is created by the kernel. Furthermore, the resulting core dump files are too large, impacting system performance.

[0006] Therefore, a new method for generating a core dump file is needed to optimize the above processing process. Summary of the Invention

[0007] To this end, the present invention provides a solution for generating a core dump file, in an effort to solve or at least alleviate the above problems.

[0008] According to one aspect of the present invention, a method for generating a core dump file is provided, comprising the following steps: first, monitoring the status of a target program, wherein a preload library is embedded in the target program; if an exception occurs in the target program, copying the current process of the target program to generate a new process corresponding to the current process; based on the new process, obtaining associated data of the current process; and dumping the associated data to generate a core dump file.

[0009] Optionally, in the method for generating a core dump file according to the present invention, the step of monitoring the status of the target program includes: loading a preload library after the target program runs; and monitoring abnormal events of the target program by registering a signal processing function in the preload library.

[0010] Optionally, in the method for generating a core dump file according to the present invention, the step of copying the current process of the target program to generate a new process corresponding to the current process includes: calling a signal processing function in a preloaded library; and copying a new process of the current process through the signal processing function.

[0011] Optionally, in the method for generating a core dump file according to the present invention, before the step of obtaining associated data of the current process based on the new process, it also includes: setting the new process to attach to the current process to track the current process and obtain access rights to the associated data of the current process.

[0012] Optionally, in the method for generating a core dump file according to the present invention, the step of obtaining associated data of the current process based on the new process includes: calling a data capture function in a preload library to obtain associated data of the current process, where the associated data includes context data and memory data of all threads of the current process.

[0013] Optionally, in the method for generating a core dump file according to the present invention, the associated data is dumped, and the step of generating a core dump file includes: obtaining the version number of the target program, the timestamp when the target program has an exception, the number of threads of the current line process, and the thread identifier of the exception from the associated data, and combining them to form a file header; calling the data processing function in the preload library, compressing other data in the associated data, and then generating a core dump file in combination with the file header and storing it.

[0014] Optionally, the method for generating a core dump file according to the present invention further includes: after the core dump file is generated, ending the dump processing through a new process.

[0015] Optionally, the method for generating a core dump file according to the present invention also includes: pre-generating a preload library, the preload library including a signal processing function, a data capture function, a data processing function and a dump configuration function; and embedding the preload library into the target program to track the target program.

[0016] According to another aspect of the present invention, a computing device is provided, comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be suitable for execution by the at least one processor, and the program instructions include instructions for executing the method for generating a core dump file as described above.

[0017] According to another aspect of the present invention, a readable storage medium storing program instructions is provided. When the program instructions are read and executed by a computing device, the computing device executes the above method for generating a core dump file.

[0018] According to the core dump file generation scheme of the present invention, when an exception occurs in a target program, a new process is created that copies the current process of the target program. Based on this new process, the associated data of the current process is obtained. The associated data is then dumped to generate a core dump file. This enables the generation of a core dump file in user mode without requiring root privileges, reduces the size of the core dump file, and mitigates the impact of core dump file generation on system performance. In addition, some data in the core dump file is compressed, ensuring a certain degree of confidentiality. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] To achieve the above and related purposes, certain illustrative aspects are described herein in conjunction with the following description and accompanying drawings, which indicate various ways in which the principles disclosed herein may be practiced, and all aspects and their equivalents are intended to fall within the scope of the claimed subject matter. The above and other objects, features, and advantages of the present disclosure will become more apparent by reading the following detailed description in conjunction with the accompanying drawings. Throughout this disclosure, the same reference numerals generally refer to the same parts or elements.

[0020] Figure 1 shows a structural block diagram of a computing device 100 according to an embodiment of the present invention;

[0021] Figure 2 A flow chart of a method 200 for generating a core dump file according to an embodiment of the present invention is shown;

[0022] Figure 3 A schematic diagram 300 of a preload library according to one embodiment of the present invention is shown;

[0023] Figure 4 A schematic diagram 400 showing the composition of a running program according to one embodiment of the present invention; and

[0024] Figure 5 A schematic diagram 500 of generating a core dump file according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0025] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0026] Figure 1 FIG. 1 shows a structural block diagram of a computing device 100 according to an embodiment of the present invention.

[0027] like Figure 1 As shown, in a basic configuration 102, computing device 100 typically includes system memory 106 and one or more processors 104. A memory bus 108 may be used for communication between processor 104 and system memory 106.

[0028] Depending on the desired configuration, the processor 104 can be any type of processor, including but not limited to: a microprocessor (UP), a microcontroller (UC), a digital signal processing unit (DSP), or any combination thereof. The processor 104 can include one or more levels of cache, such as a level 1 cache 110 and a level 2 cache 112, a processor core 114, and registers 116. An example processor core 114 can include an arithmetic logic unit (ALU), a floating point unit (FPU), a digital signal processing core (DSP core), or any combination thereof. An example memory controller 118 can be used with the processor 104, or in some implementations, the memory controller 118 can be an internal part of the processor 104.

[0029] Depending on the desired configuration, system memory 106 can be any type of memory, including but not limited to volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. System memory 106 can include an operating system 120, one or more applications 122, and program data 124. In some embodiments, application 122 can be arranged to execute instructions on the operating system by one or more processors 104 using program data 124.

[0030] Computing device 100 also includes storage 132 , which includes removable storage 136 and non-removable storage 138 .

[0031] The computing device 100 may also include a storage interface bus 134. The storage interface bus 134 enables communication from storage devices 132 (e.g., removable storage 136 and non-removable storage 138) to the basic configuration 102 via the bus / interface controller 130. At least a portion of the operating system 120, applications 122, and program data 124 may be stored on the removable storage 136 and / or the non-removable storage 138 and loaded into the system memory 106 via the storage interface bus 134 when the computing device 100 is powered on or when the application 122 is to be executed, and executed by the one or more processors 104.

[0032] The computing device 100 may also include an interface bus 140 that facilitates communication from various interface devices (e.g., output devices 142, peripheral interfaces 144, and communication devices 146) to the basic configuration 102 via the bus / interface controller 130. Example output devices 142 include an image processing unit 148 and an audio processing unit 150. These can be configured to facilitate communication with various external devices such as a display or speakers via one or more A / V ports 152. Example peripheral interfaces 144 may include a serial interface controller 154 and a parallel interface controller 156, which can be configured to facilitate communication with external devices such as input devices (e.g., a keyboard, mouse, pen, voice input device, touch input device) or other peripherals (e.g., a printer, scanner, etc.) via one or more I / O ports 158. Example communication devices 146 may include a network controller 160, which can be arranged to facilitate communication with one or more other computing devices 162 via a network communication link via one or more communication ports 164.

[0033] A network communication link can be an example of a communication medium. Communication media can generally be embodied as computer-readable instructions, data structures, program modules in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery medium. A "modulated data signal" can be a signal in which one or more of a data set or a change therein can be carried out in a manner that encodes information in the signal. As non-limiting examples, communication media can include wired media such as a wired network or a dedicated line network, and various wireless media such as sound, radio frequency (RF), microwave, infrared (IR) or other wireless media. The term computer-readable medium as used herein can include both storage media and communication media.

[0034] The computing device 100 can be implemented as a personal computer including desktop and notebook computer configurations. Of course, the computing device 100 can also be implemented as part of a small-sized portable (or mobile) electronic device, such as a cellular phone, a digital camera, a personal digital assistant (PDA), a personal media player device, a wireless network browsing device, a personal head-mounted device, an application-specific device, or a hybrid device that can include any of the above functions. It can even be implemented as a server, such as a file server, a database server, an application server, and a web server. The embodiments of the present invention are not limited to this.

[0035] In an embodiment according to the present invention, the computing device 100 is configured to execute the method 200 for generating a core dump file according to the present invention. The application 122 disposed on the operating system includes a plurality of program instructions for executing the method 200 for generating a core dump file according to the present invention. These program instructions can instruct the processor 104 to execute the method 200 for generating a core dump file according to the present invention, so that the computing device 200 generates a core dump file by executing the method 200 for generating a core dump file according to the present invention.

[0036] Figure 2 The flowchart of a method 200 for generating a core dump file according to one embodiment of the present invention is shown. The method 200 for generating a core dump file may be executed in a computing device (eg, the aforementioned computing device 100).

[0037] like Figure 2 As shown, method 200 begins at step S210. In step S210, the state of a target program is monitored, wherein the target program has a preload library embedded therein. According to one embodiment of the present invention, the state of the target program can be monitored in the following manner. First, after the target program is running, the preload library is loaded, and then abnormal events of the target program are monitored by registering a signal processing function in the preload library.

[0038] The target program here can be a program or application included in the aforementioned application 122, such as a browser. The preload library mentioned above usually needs to be generated in advance so that after the target program starts running, the target program can be tracked, thereby obtaining related data to generate a core dump file when an exception occurs in the target program. To facilitate understanding and subsequent description, the relevant content of the preload library is first explained here.

[0039] According to another embodiment of the present invention, method 200 further includes pre-generating a preload library and embedding the preload library into the target program to track the target program. In this embodiment, taking the Linux system as an example, the preload library is a preload library, which can provide a series of functions, programs, or commands to help obtain relevant information of the target program. Figure 3 Schematic diagram 300 of a preload library according to one embodiment of the present invention is shown. Figure 3 As shown, the preload library includes signal processing functions, data capture functions, data processing functions, and dump configuration functions.

[0040] In the preload library, the signal processing function can capture system exception signals such as SIGSEGV (segmentation fault information), so that the signal processing function can be used to monitor whether the target program being tracked has an exception, such as whether a process crash has occurred, so as to copy a new process of the crashed process. The data capture function can capture the associated data of the crashed process, that is, to obtain the context data and memory data of all threads of the crashed process, and the data processing function can process the associated data to generate a core dump file. The dump configuration function is generally used to configure the type and size of memory data to be dumped, and can be called when loading the preload library to complete the relevant configuration of the memory data. The above-mentioned preload library supports the use of environment variables to specify the configuration file path, and uses the JSON (JavaScript Object Notation) file as the configuration file to control the size of the data to be dumped. The environment variable setting command is as follows:

[0041] CORE_CONFIG_FILE= / path / to / new / core.json

[0042] The configuration file format is as follows:

[0043]

[0044] The meaning of each field is as follows:

[0045] dump_dir: string type, specifies the directory path of the file to be dumped, the default is / home / your-name / .local / share / core / ;

[0046] stacks: dictionary type, specifies how to dump thread stack data;

[0047] max_size (in stacks): integer type, specifies the maximum size of each thread stack to be dumped, in KB (Kilobyte), the default is 32KB;

[0048] modules: string array type, specifies which modules’ writable memory segments are dumped;

[0049] variables: dictionary array, specifying the global variable data to be dumped:

[0050] name: string type, specifies the name of the global variable. If the production environment does not have debugging symbols, you can use the module name plus the address offset value;

[0051] max_size (in variables), integer type, specifies the maximum memory value of global variable dump, in KB;

[0052] is_pointer: Boolean type. When true, it means that the global variable is a pointer. If it is a pointer, max_size is the size of the memory pointed to by this pointer.

[0053] The following is an example of the core code of the preload library:

[0054]

[0055] After the preload library is generated, the program to be tracked can be determined, the program can be used as the target program, and the preload library can be embedded into the target program to start running the target program. Figure 4 FIG. 4 shows a schematic diagram 400 of the composition of a running program according to an embodiment of the present invention. Figure 4 As shown in the figure, the target program consists of a compiled application (which can be understood as the target program itself), a preload library (a preload library for core dumps), a system library (such as the C language function library libc under Linux), and third-party dependent libraries.

[0056] Returning to step S210, after the target program is running, the preload library is loaded first, and by registering signal processing functions such as SIGSEGV in the preload library, the abnormal events of the target program are monitored to determine whether the current process of the target program has crashed.

[0057] Then, step S220 is entered. If an exception occurs in the target program, the current process of the target program is copied to generate a new process corresponding to the current process. According to one embodiment of the present invention, the new process can be generated in the following manner. Specifically, a signal processing function in a preloaded library is first called, and then a new process of the current process is copied through the signal processing function.

[0058] In this embodiment, when the current process of the target program crashes, the signal processing function detects that an exception has occurred in the target program, and then copies (or clones) the current process of the target program through the signal processing function to generate a new process of the current process. The new process has only one thread and shares the process space and file system with the current process.

[0059] Next, in step S230, the associated data of the current process is obtained based on the new process. Before obtaining the associated data, the new process needs to be processed in order to obtain access rights to the associated data. According to another embodiment of the present invention, before obtaining the associated data of the current process based on the new process, the new process is set to attach to the current process to track the current process and obtain access rights to the associated data of the current process. In this embodiment, the PTRACE_ATTACH command is called to attach the current process. Here, the meaning of attachment is that the copied new process is the tracking process of the current process and has the right to access the associated data of the current process, that is, the context data and memory data.

[0060] When obtaining associated data, the data capture function in the preloaded library can be called to obtain the associated data of the current process. The associated data includes the context data and memory data of all threads of the current process. For example, the data capture function includes a series of subcommands of PTRACE, calling the PTRACE_GETREGS command to access general registers, calling the PTRACE_GETFPREGS command to access floating-point registers, calling the PTRACE_PEEKUSER and PTRACE_PEEKDATA commands to access memory, and obtaining the context data and memory data of all threads of the current process.

[0061] Finally, step S240 is executed to dump the associated data and generate a core dump file. According to one embodiment of the present invention, the dump process can be completed to generate a core dump file in the following manner. First, the version number of the target program, the timestamp when the target program has an exception, the number of threads of the current line process, and the thread identifier of the exception are obtained from the associated data, and the combination is formed into a file header. Then, the data processing function in the preload library is called, and after compressing the other data in the associated data, the core dump file is generated and stored in combination with the file header.

[0062] In this embodiment, the core dump file has a custom format. Its file header is generally 16 bytes, of which the version number of the target program is 4 bytes, the timestamp when the target program is abnormal is 8 bytes, the number of threads of the current process is 2 bytes, and the thread identifier of the abnormal thread is 2 bytes. In addition to the 16-byte file header, the remaining data in the associated data can be encoded using zstd

[0063] (Zstandard, a fast data compression algorithm) is used as a data processing function to compress and write to a local disk file for storage, so that the generated core dump file has a certain degree of confidentiality.

[0064] The following is an example of the format of a core dump file:

[0065]

[0066]

[0067] CPU and TSL stand for Central Processing Unit and Transport Layer Security, respectively. The advantage of a custom core dump file format is its simple structure. The smallest unit is a data block. Each data block begins with a data length followed by specific data. Multiple data blocks are concatenated according to the custom format.

[0068] For example, when a video application plays a 720P (Progressive Scanning) video and an exception occurs, the sizes of the core dump files generated in three ways are shown in the following table:

[0069] Way Core dump file size Conventional kernel mode 625MB Breakpad default mode 718KB Technical solution of the present invention 88KB

[0070] Table 1

[0071] Table 1 shows the core dump file sizes generated by three methods according to an embodiment of the present invention, wherein the conventional kernel method is a method for controlling the core dump file size based on the virtual configuration file provided by the new version of the Linux kernel, and the core dump file generated is 625M. Breakpad is a cross-platform crash reporting service open sourced by Google, which includes a client and a server. The client is responsible for generating the context information of the crashed process, saving it to its customized minidump file, and uploading it to the server. The server outputs the crashed thread call stack information based on the symbolic information of the saved program. The core dump file obtained by the Breakpad default method is 718KB. According to the technical solution of the present invention, the core dump file finally generated is only 88KB, which greatly reduces the occupied space of the core dump file and reduces the impact of the generation process on system performance.

[0072] According to another embodiment of the present invention, after the core dump file is generated, the dump process is terminated by the new process. At this moment, the new process calls the exit (withdrawal) function and actively withdraws, and the current process that collapses also withdraws subsequently.

[0073] Figure 5 FIG. 5 shows a schematic diagram 500 of generating a core dump file according to an embodiment of the present invention. Figure 4 As shown, when an exception occurs in the target program, the kernel calls the signal handling function registered in the preload library, creates a new process that copies the target program's current process. This new process then attaches to the target program's current process and uses a series of PTRACE subcommands to access the current process's associated data, namely the context data and memory data of all threads, such as CPU registers and each thread's stack data. This associated data is then dumped, generating a core dump file and saving it to disk. During this process, the signal handling function waits until the new thread completes the dump processing. Once the new thread exits, the current process also exits.

[0074] After obtaining the core dump file, the file header can be parsed and the remaining data in the core dump file, excluding the header, can be decompressed and subsequently filled in according to the standard core dump file format to obtain a complete standard core dump file, which can then be automatically viewed using GDB (GNU symbolic debugger). The standard core dump file format is similar to the organizational structure of ELF (Executable and Linkable Format) files and can be viewed using the "readelf -e" command. It generally has an ELF file header and N program headers.

[0075] According to the core dump file generation scheme of the embodiment of the present invention, a series of functions of the preload library are based on monitoring the target program and obtaining the associated data of the current process when an exception occurs in the target program, thereby realizing the customization of the core dump file, having a certain confidentiality, and flexibly configuring the process memory data to be dumped, without the need for root permissions, and quickly generating the core dump file according to the associated data in the user state, reducing the size of the core dump file and reducing the impact of the generation process on the system performance.

[0076] The various techniques described herein may be implemented in conjunction with hardware or software, or a combination thereof. Thus, the methods and apparatus of the present invention, or certain aspects or portions of the methods and apparatus of the present invention, may be implemented in the form of program codes (i.e., instructions) embedded in a tangible medium, such as a removable hard disk, a USB flash drive, a floppy disk, a CD-ROM, or any other machine-readable storage medium, wherein when the program is loaded into a machine such as a computer and executed by the machine, the machine becomes an apparatus for practicing the present invention.

[0077] When program code is executed on a programmable computer, the computing device generally includes a processor, a storage medium readable by the processor (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The memory is configured to store the program code; and the processor is configured to execute the core dump file generation method of the present invention according to instructions in the program code stored in the memory.

[0078] By way of example and not limitation, readable media include readable storage media and communication media. Readable storage media store information such as computer-readable instructions, data structures, program modules, or other data. Communication media typically embody computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and include any information delivery medium. Combinations of any of the above are also included within the scope of readable media.

[0079] In the description provided herein, the algorithms and displays are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems may also be used in conjunction with the examples of the present invention. Based on the above description, it is apparent that the structure required for constructing such systems is well understood. In addition, the present invention is not directed to any specific programming language. It should be understood that various programming languages ​​may be utilized to implement the present invention described herein, and the description of specific languages ​​above is provided for the purpose of disclosing the preferred embodiment of the present invention.

[0080] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of this description.

[0081] Similarly, it should be understood that in order to streamline the present disclosure and aid understanding of one or more of the various inventive aspects, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the claims, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Accordingly, the claims that follow the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of the invention.

[0082] Those skilled in the art will appreciate that the modules, units, or components of the devices in the examples disclosed herein may be arranged in the device described in the embodiment, or alternatively may be located in one or more devices different from the devices in the examples. The modules in the foregoing examples may be combined into one module or further divided into multiple submodules.

[0083] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition may be divided into multiple submodules or subunits or subcomponents. All features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed herein may be combined in any combination, except that at least some of such features and / or processes or units are mutually exclusive. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0084] Furthermore, those skilled in the art will appreciate that although some embodiments described herein include certain features included in other embodiments but not other features, combinations of features from different embodiments are intended to be within the scope of the present invention and to form different embodiments. For example, in the claims, any of the claimed embodiments may be used in any combination.

[0085] In addition, some of the embodiments are described herein as methods or combinations of method elements that can be implemented by a processor of a computer system or by other devices that perform the functions described. Thus, a processor having the necessary instructions for implementing the method or method element forms a device for implementing the method or method element. Furthermore, the elements described herein of the device embodiments are examples of devices for implementing the functions performed by the elements for the purpose of implementing the invention.

[0086] As used herein, unless otherwise specified, the use of ordinal numbers "first," "second," "third," etc. to describe common objects merely indicates that different instances of similar objects are involved and are not intended to imply that the objects so described must have a given order in time, space, ranking, or in any other manner.

[0087] Although the present invention has been described with respect to a limited number of embodiments, it will be apparent to those skilled in the art, having benefit of the foregoing description, that other embodiments are contemplated within the scope of the invention thus described. Furthermore, it should be noted that the language used in this specification has been selected primarily for readability and didactic purposes, rather than for the purpose of explaining or limiting the subject matter of the present invention. Consequently, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the present invention is intended to be illustrative rather than restrictive of the scope of the invention, which is defined by the appended claims.

Claims

1. A method for generating a core dump file, comprising: Monitoring the state of a target program, wherein a preload library is embedded in the target program, and the preload library includes a signal processing function, a data capture function, a data processing function, and a dump configuration function, wherein the dump configuration function is used to configure the type and size of memory data to be dumped; If an exception occurs in the target program, copy the current process of the target program to generate a new process corresponding to the current process; Setting the new process to attach to the current process to track the current process and obtain access rights to associated data of the current process; Based on the new process, obtaining associated data of the current process; The associated data is dumped to generate a core dump file, specifically including: obtaining the version number of the target program, the timestamp when the target program has an exception, the number of threads of the current process, and the thread identifier of the exception from the associated data, combining them to form a file header, calling the data processing function in the preload library, compressing other data in the associated data, and then generating a core dump file in combination with the file header and performing the process, wherein the core dump file stores the version number of the target program, the timestamp when the exception has occurred, the number of threads of the current process, and the thread identifier of the exception in a preset format in sequence, so that the core dump file can be parsed according to the preset format to improve the confidentiality of the core dump file.

2. The method according to claim 1, wherein The step of monitoring the status of the target program includes: After the target program is run, loading the preload library; By registering the signal processing function in the preload library, abnormal events of the target program are monitored.

3. The method according to claim 1 or 2, wherein the step of copying the current process of the target program to generate a new process corresponding to the current process comprises: Calling the signal processing function in the preloaded library; A new process of the current process is copied through the signal processing function.

4. The method according to claim 3, wherein: The step of obtaining the associated data of the current process based on the new process includes: The data capture function in the preload library is called to obtain the associated data of the current process, where the associated data includes context data and memory data of all threads of the current process.

5. The method of claim 3, further comprising: After the core dump file is generated, the dump processing is ended through the new process.

6. The method of claim 3, further comprising: Pre-generating the preload library; The preload library is embedded into the target program to track the target program.

7. A computing device comprising: at least one processor; as well as A memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, and the program instructions include instructions for executing the method according to any one of claims 1 to 6.

8. A readable storage medium storing program instructions, wherein when the program instructions are read and executed by a computing device, the computing device executes the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Application crash analysis method and system

    CN106649089A

  • Method and device for obtaining process crash information, medium and electronic equipment

    CN110727566A