Method, device and electronic equipment for generating core dump file

By generating core dump files containing basic process characteristics and real-time scenario characteristics through multiple core dump parameter templates and generalized template parsing algorithms, the problem that the path and file name of core dump files in Linux systems cannot represent the process scenario is solved, and the effect of rapid identification and analysis is achieved.

CN116627897BActive Publication Date: 2026-05-01NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NETEASE (HANGZHOU) NETWORK CO LTD
Filing Date
2023-04-10
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

In Linux systems, the path and filename of a kernel dump file can only represent the common characteristics of a process and cannot characterize the real-time scenario characteristics of the target process, making it difficult to quickly identify and analyze different process execution scenarios.

Method used

Multiple core dump parameter templates are used, combined with memory snapshots and basic core dump information, to generate a core dump file containing the basic characteristics of the target process and the real-time scene characteristics. The memory snapshot is transferred to the core dumper through a pipeline, and the path file name is generated using a generalized template definition and parsing algorithm.

Benefits of technology

It improves the efficiency of core dump file identification and analysis, enabling rapid identification of process execution scenarios and provision of relevant service information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116627897B_ABST
    Figure CN116627897B_ABST
Patent Text Reader

Abstract

The application provides a core dump file generation method and device and electronic equipment. In response to a core dump event of a target process, a memory snapshot and basic core dump information of the target process are obtained. Based on a plurality of preset core dump parameter templates and the basic core dump information, a target core dump parameter template corresponding to the target process is determined. Based on the target core dump parameter template and the basic core dump information, storage parameters of a core dump file of the target process are determined. Based on the storage parameters and the memory snapshot, the core dump file of the target process is generated. In this way, the parameters in the target core dump parameter template can represent the basic characteristics and the instant scene characteristics of the target process. Therefore, the storage parameters generated based on the template can quickly identify the process execution scene corresponding to the core dump file, provide related services, and improve the efficiency of identifying and analyzing the core dump file of the target process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and more specifically, to a method, apparatus, and electronic device for generating core dump files. Background Technology

[0002] When a Linux system responds to a kernel dump signal, it replaces the system template parameters in the core file template with specific parameter values ​​to obtain the path and filename of the core file. The system template parameters are located in the core file template defined in the system file. Then, it writes a snapshot of the target process's memory at that time to the core file. However, the Linux system file " / proc / sys / kernel / core_pattern" can only define one core file template. This template is a common template used when generating core files for a process. Therefore, the path and filename of the generated core file can only represent the common characteristics of the process represented by the system template parameters, and cannot represent the real-time characteristics of the target process in different process execution scenarios, such as which scenario it serves or what services it provides. This makes it difficult to meet the needs of rapid identification and analysis of core dump files of such target processes. Summary of the Invention

[0003] In view of this, the purpose of the present invention is to provide a method, apparatus and electronic device for generating core dump files, so as to improve the efficiency of identifying and analyzing core dump files of target processes.

[0004] In a first aspect, embodiments of the present invention provide a method for generating a core dump file, comprising: responding to a core dump event for a target process, obtaining a memory snapshot and basic core dump information of the target process; determining a target core dump parameter template corresponding to the target process based on a plurality of preset core dump parameter templates and the basic core dump information; wherein, the core dump parameter template includes a plurality of core dump parameters; the core dump parameters are used to: characterize the basic features or real-time scene features of the target process; determining the storage parameters of the core dump file of the target process based on the target core dump parameter template and the basic core dump information; and generating the core dump file of the target process based on the storage parameters and the memory snapshot.

[0005] Secondly, embodiments of the present invention provide a core dump file generation apparatus, comprising: a memory snapshot and basic core dump information acquisition module, used to acquire a memory snapshot of the target process in response to a core dump event for the target process; a target core dump parameter template determination module, used to determine a target core dump parameter template corresponding to the target process based on a plurality of preset core dump parameter templates and basic core dump information; wherein, the core dump parameter template includes a plurality of core dump parameters; the core dump parameters are used to characterize the basic features or real-time scene features of the target process; a storage parameter determination module, used to determine the storage parameters of the core dump file of the target process based on the target core dump parameter template and basic core dump information; and a file generation module, used to generate the core dump file of the target process based on the storage parameters and the memory snapshot.

[0006] Thirdly, embodiments of the present invention provide an electronic device, including a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above-described method for generating a core dump file.

[0007] Fourthly, embodiments of the present invention provide a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are invoked and executed by a processor, the machine-executable instructions cause the processor to implement the above-described method for generating a core dump file.

[0008] The embodiments of the present invention bring the following beneficial effects:

[0009] The aforementioned method, apparatus, and electronic device for generating core dump files respond to a core dump event targeting a target process by acquiring a memory snapshot and basic core dump information of the target process; determining a target core dump parameter template corresponding to the target process based on multiple preset core dump parameter templates and the basic core dump information; wherein, the core dump parameter template includes multiple core dump parameters; the core dump parameters are used to: characterize the basic characteristics or real-time scenario characteristics of the target process; determine the storage parameters of the core dump file of the target process based on the target core dump parameter template and the basic core dump information; and generate the core dump file of the target process based on the storage parameters and the memory snapshot. In this method, the parameters in the target core dump parameter template can characterize the basic characteristics and real-time scenario characteristics of the target process. Therefore, by using the storage parameters generated based on this template, the process execution scenario and related services provided by the core dump file can be quickly identified, improving the efficiency of identifying and analyzing the core dump file of the target process.

[0010] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.

[0011] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0012] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0013] Figure 1 A flowchart illustrating a method for generating a core dump file according to an embodiment of the present invention;

[0014] Figure 2 This is a schematic diagram of the core dump provided in an embodiment of the present invention;

[0015] Figure 3 A flowchart of a generalized template parameter parsing process is provided for an embodiment of the present invention;

[0016] Figure 4 A flowchart of a generalized template parameter parsing process provided in an embodiment of the present invention;

[0017] Figure 5 A flowchart of a generalized template parameter parsing process provided in an embodiment of the present invention;

[0018] Figure 6 A flowchart of a generalized template parameter parsing process provided in an embodiment of the present invention;

[0019] Figure 7 A schematic diagram of a core dump file generation device provided in an embodiment of the present invention;

[0020] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0022] On Linux systems, core dump technology generates a core dump file (also known as a "core file") that stores a memory snapshot of a process. This file can be used for process restoration, program debugging, problem analysis, and anomaly alerts.

[0023] The template parameters (also referred to as "template parameters") in the Linux system core file template are shown in Table 1. When the system responds to a kernel dump signal, it replaces the template parameters in the core file template defined in the system file " / proc / sys / kernel / core_pattern" with their corresponding values, thereby obtaining the storage path and filename of the core file (which can be uniformly referred to as "path-filename"). Then, it writes the memory snapshot of the target process at that time into the core file. For example, when the core file template is " / home / zhoucun / coredump / core.%p.%e.%t", after the process gameserver-release replaces the parameters %p, %e, and %t with their corresponding values, the string " / home / zhoucun / coredump / core.24207.gameserver-rele.1665721975" is obtained. This string is the path-filename of the core file, where the path is " / home / zhoucun / coredump" and the filename is "core.24207.gameserver-rele.1665721975".

[0024] Table 1

[0025]

[0026] Because the Linux system file " / proc / sys / kernel / core_pattern" can only define one core file template, which is a common template used when generating core files for any process, and cannot define a dedicated core file template for a specific process, the path and filename of the generated core file can only represent the common characteristics of the process represented by the system template parameter, and cannot represent the personalized characteristics of the process. For example, it cannot meet the requirements of the three example application scenarios described below.

[0027] Scene 1:

[0028] For the executable file " / home / zhoucun / shoppingserver", after startup, the processes can load different configuration files to provide different services. Table 2 shows seven shoppingserver processes representing the services fruit1-1-8-1, fruit1-1-8-2, fruit2-1-8-1, vegetable1-1-9-1, vegetable2-1-9-1, drinks1-1-10-3, and drinks2-1-10-1, respectively. Ideally, the path and filename of the core file generated when the shoppingserver process terminates should include the process service characteristics (i.e., fruit1-1-8-1, fruit1-1-8-2, fruit2-1-8-1, vegetable1-1-9-1, vegetable2-1-9-1, drinks1-1-10-3, and drinks2-1-10-1) to quickly identify which process responsible for which service, shoppingserver, has terminated.

[0029] Table 2

[0030]

[0031]

[0032]

[0033] Scene 2:

[0034] For the executable file " / home / zhoucun / gameserver / version number / gameserver", after startup, the process reads different scene IDs to serve different scenes, as shown in Table 3. It is desirable that the path and filename of the core file generated when the gameserver process terminates include the executable version number (e.g., 2.1.123567.15) and scene ID (e.g., 218613561) to quickly identify which version and which scene the gameserver process responsible for has terminated.

[0035] Table 3

[0036]

[0037] Scene 3:

[0038] If the executable file itself uses the `setrlimit` function to set the soft limit of resource `RLIMIT_CORE` to 0 (i.e., the soft limit for core file size is 0), then the Linux system will not generate a core file for processes launched by this type of executable file. The goal is to generate a core file for processes launched by this type of executable file for purposes such as error alerting or problem analysis.

[0039] Based on this, embodiments of the present invention provide a method, apparatus, and electronic device for generating core dump files.

[0040] See Figure 1 First, a method for generating a core dump file provided by an embodiment of the present invention will be introduced. The method includes the following steps:

[0041] Step S102: In response to the core dump event for the target process, obtain the memory snapshot and basic core dump information of the target process.

[0042] After a kernel dump event occurs, a fully usable copy of the relevant data for the target process is typically generated. This copy includes an image of the corresponding data at a specific point in time (the time the copy begins), i.e., the aforementioned memory snapshot. The data saved in the memory snapshot can include the current execution state of the target process, data referenced by the target process, and data generated by the target process, etc., and is suitable for analyzing the current execution process of the target process.

[0043] The aforementioned basic core dump information typically includes basic information about the target process, such as the target process identifier, the storage information of the corresponding executable file (such as the storage path and file name), and relevant parameters of the core dump event (such as the trigger time and trigger signal of the core dump event).

[0044] Step S104: Based on multiple preset core dump parameter templates and basic core dump information, determine the target core dump parameter template corresponding to the target process; wherein, the core dump parameter template includes multiple core dump parameters; the core dump parameters are used to characterize the basic features or real-time scene features of the target process.

[0045] The core dump parameters mentioned above can be of various types, such as the occurrence time of the core dump event of the target process, the filename of the executable file of the process, the process identifier, and other core dump parameters that can characterize the basic features of the target process, as shown in Table 1 above. ;It can also include the version information of the executable file running by the target process, the configuration parameters referenced by the target process, and scenario information during the execution of the target process. The parameter values ​​corresponding to these parameters are specific to the current execution process and can characterize the real-time scenario characteristics of the target process in this kernel dump event. Kernel dump parameters are recorded through kernel dump parameter templates. The above-mentioned multiple kernel dump parameter templates are typically applied to different process execution scenarios. Therefore, it is necessary to determine the target kernel dump parameter template corresponding to the target process based on application requirements and the real-time scenario characteristics of the target process.

[0046] Step S106: Based on the target core dump parameter template and the basic core dump information, determine the storage parameters of the target process's core dump file.

[0047] After determining the target core dump parameter template corresponding to the target process, it is necessary to parse the basic core dump information or generate the required information based on the basic core dump information to determine the parameter values ​​corresponding to the core dump parameters in the target core dump parameter template. Furthermore, based on these parameter values ​​corresponding to the core dump parameters, the storage parameters for the core dump file can be generated.

[0048] The aforementioned storage parameters typically include the storage path and filename. The core dump parameters in the target core dump parameter template can be arranged in a set order, and storage parameters are generated based on the core dump parameter template, the core dump parameters, and their corresponding parameter values.

[0049] Step S108: Based on storage parameters and memory snapshots, generate the core dump file of the target process.

[0050] In practice, an empty file needs to be generated based on the storage parameters, and then some or all of the data in the memory snapshot is saved to the empty file. The specific amount of data can be set according to the requirements.

[0051] The aforementioned method for generating core dump files involves responding to a core dump event targeting a target process, acquiring a memory snapshot and basic core dump information of the target process; determining a target core dump parameter template corresponding to the target process based on multiple preset core dump parameter templates and the basic core dump information; wherein the core dump parameter template includes multiple core dump parameters; the core dump parameters are used to: characterize the basic characteristics or real-time scenario characteristics of the target process; determining the storage parameters of the target process's core dump file based on the target core dump parameter template and the basic core dump information; and generating the target process's core dump file based on the storage parameters and the memory snapshot. In this method, the parameters in the target core dump parameter template can characterize the basic characteristics and real-time scenario characteristics of the target process. Therefore, by using the storage parameters generated based on this template, the process execution scenario and related services provided by the core dump file can be quickly identified, improving the efficiency of identifying and analyzing the target process's core dump file.

[0052] The following embodiments provide an implementation method for determining the target core dump parameter template corresponding to the target process based on multiple preset core dump parameter templates and basic core dump information.

[0053] In practical implementation, the executable file information of the target process can be extracted from the basic core dump information. Furthermore, based on multiple preset core dump parameter templates and executable file information, the target core dump parameter template corresponding to the target process can be determined.

[0054] When determining the target kernel dump parameter template, the executable file information of the target process needs to be matched with the extended parameter template (the extended parameter template corresponds to the set executable file information) to obtain the matching result. Further, based on the matching result, the target kernel dump parameter template corresponding to the target process is determined. Specifically, the aforementioned set executable file information can be set file storage information, a first set file name, or an fuzzy file name; where the file storage information typically includes a set storage path and a second set file name stored in the set storage path. The executable file information of the target process includes the storage path and file name of the executable file.

[0055] During the matching process, firstly, based on the storage path and filename of the executable file of the target process, a first equality comparison search is performed on the storage information of the set file corresponding to the first extended parameter template among multiple extended parameter templates; the first extended parameter template may not exist. If it does not exist, the process of matching the set executable file information corresponding to the second extended parameter template can be directly executed; if the result of the first equality comparison search is not empty, the matching result is determined to be: the target process matches the retrieved first extended parameter template.

[0056] If the result of the first equality comparison search is empty, a second equality comparison search is performed on the first set filename corresponding to the second extended parameter template among multiple extended parameter templates, based on the filename of the executable file of the target process. As mentioned above, the second extended parameter template may not exist, in which case the process of matching the set executable file information corresponding to the third extended parameter template can be directly executed. If the result of the second equality comparison search is not empty, the matching result is determined to be: the target process matches the retrieved second extended parameter template.

[0057] If the result of the second equality comparison search is empty, a fuzzy comparison search is performed on the fuzzy filename corresponding to the third extended parameter template among multiple extended parameter templates, based on the filename of the executable file of the target process; if the third extended parameter template does not exist, the search can be stopped directly. If the result of the fuzzy comparison search is not empty, the matching result is determined to be: the target process matches the retrieved third extended parameter template; if the result of the fuzzy comparison search is empty, the matching result is determined to be empty.

[0058] After determining the matching result, if the matching result is that the target process matches the target extended parameter template among multiple extended parameter templates, the target extended parameter template is determined as the target core dump parameter template corresponding to the target process; if the matching result is empty, the common template is determined as the target core dump parameter template corresponding to the target process.

[0059] The following embodiments provide an implementation method for determining the storage parameters of the core dump file of a target process based on the target core dump parameter template and the basic core dump information.

[0060] When determining the storage parameters, it is necessary to obtain the parameter values ​​corresponding to the target core dump parameters from the basic core dump information or the information generated based on the basic core dump information for each target core dump parameter corresponding to the target process. Then, based on the preset algorithm and the parameter values ​​of the target core dump parameters corresponding to the target process, the storage parameters of the target process's core dump file are generated.

[0061] The storage parameters mentioned above can include filenames, as well as absolute or relative paths. The specific settings can be configured according to requirements and are not limited here.

[0062] The following embodiments provide an implementation method for generating a core dump file of a target process based on storage parameters and memory snapshots.

[0063] When the storage parameters include the target storage path and the target file name, a first file is generated based on the target storage path and the file name; at this time, the content of the first file is empty; then the target process memory snapshot data is stored in the first file, and the first file storing the target process memory snapshot data is determined as the core dump file of the target process.

[0064] This invention provides a method for generating a core dump file, which in... Figure 1 This method is implemented based on the method shown. It designs a generalized template and parameters for the core dump file, and develops a core dumper that includes a generalized template definition and a generalized template parsing algorithm. It also employs a technique of pipering process memory snapshots to the core dumper. When the Linux system responds to a core dump signal, the core dumper automatically runs. The core dumper generates the path and filename of the core file based on the generalized template definition and the generalized template parsing algorithm, and then writes the memory snapshot of the target process into the core file. Since the generalized template of the core dump consists of a process-wide common core file template (equivalent to the "common template" mentioned above), a process-specific core file template (equivalent to the "extended parameter template" mentioned above), and generalized template parameters (which can be simply referred to as "generalized template parameters"), the generalized template parameters include Linux system template parameters (which can be simply referred to as "Linux system template parameters") and extended template parameters (which can be simply referred to as "extended template parameters"). Therefore, the path and filename of the generated core file can represent either the basic characteristics of the process represented by the generalized template parameters (which can also be called "common characteristics") or the real-time scenario characteristics of the process represented by the generalized template parameters (which can also be called "personalized characteristics").

[0065] The embodiments of the present invention include three aspects: setting up a pipeline to transmit process memory snapshots to the core dumper, defining a generalized template for the core dumper, and automatically running the core dumper to parse the generalized template and perform a core dump.

[0066] When configuring the process memory snapshot to be piped to the core dumper, the content of the Linux system file " / proc / sys / kernel / core_pattern" can be set to "| / bin / bash / xx / core_dumper.sh%e%p%h%E%s%i%t%c%d%g%I%P%u%%". Here, "xx" represents any directory, and core_dumper.sh is the core dumper.

[0067] The generalized templates for the core dumper include the process-wide core file template `core_pattern`, the process-specific core file template `executable_core_pattern`, and generalized template parameters. `core_pattern` is a string variable. `executable_core_pattern` is a descriptive variable that can define multiple data members. Each data member is a key-value pair, where the key represents the executable file and the value represents the corresponding core file template. The key is defined in three ways: the executable file's path and filename, the executable file's filename, and the executable filename containing the wildcard "*". The generalized template parameters include 14 system template parameters for the Linux system (see Table 1 above) and designed extended template parameters (as shown in Table 4).

[0068] Table 4

[0069]

[0070] The core file templates defined in both `core_pattern` and `executable_core_pattern` can contain zero or more of the generalized template parameters. An example of a generalized template definition is as follows:

[0071] core_pattern="core_%n_%p_%h_%T"

[0072] declare-A executable_core_pattern=(

[0073] ["shoppingserver"]=" / home / zhoucun / coredump1 / core_%n_^[a-zA-Z0-9]+\-[0-9]+\-[0-9]+\-[0-9]+^_%p_%h_%T"

[0074] [" / home / zhoucun / shoppingserver"] = " / home / zhoucun / coredump2 / core_%n_^[a-zA-Z0-9]+\-[0-9]+\-[0-9]+\-[0-9]+^_%p_%h_%T"

[0075] ["gameserver"]=" / home / zhoucun / coredump3 / core_%n_^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+^_^(?<=sceneid=)([0-9]+)(?=)^_%h_%p_%T"

[0076] ["gameserver-release"]=" / home / zhoucun / coredump4 / core%C_%n_^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+^_^(?<=sceneid=)([0-9]+)(?=)^_%h_%p_%T"

[0077] ["gameserver*"]=" / home / zhoucun / coredump5 / core_%n_^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+^_^(?<=sceneid=)([0-9]+)(?=)^_%h_%p_%T" )

[0079] After completing the setup for pipelining process memory snapshots to the core dumper and defining the generalized template for the core dumper, the Linux system automatically runs the core dumper to parse the generalized template and perform a core dump when responding to a core dump signal. The underlying framework is as follows: Figure 2 As shown.

[0080] When a Linux system responds to a core dump signal, it runs the core dumper as the root user, based on the setting of passing a process memory snapshot to the core dumper via a pipe. It replaces the 14 system template parameters "%e%p%h%E%s%i%t%c%d%g%I%P%u%%" with their corresponding values ​​and uses the replacement results as the core dumper's running parameters. It then passes the memory snapshot of the target process to the core dumper via a pipe as its standard input data.

[0081] For example, as shown in Table 5 below, processes 10219, 10243, 10360, and 10361 all experienced core dumps and crashes, triggered by SIGSEGV, SIGABRT, SIGFPE, and SIGILL signals, respectively. When the Linux system responds to the SIGSEGV signal, the core dumper core_dumper.sh is run as the root user. The values ​​corresponding to the 14 system template parameters "%e%p%h%E%s%i%t%c%d%g%I%P%u%%" (e.g., the value of "%p" is 10219, and the value of "%s" is 11) are its running parameters. The memory snapshot of process 10219 at this time is its standard input data. When the Linux system responds to the SIGABRT signal, the core dumper core_dumper.sh is run as the root user. Its runtime parameters are the values ​​of the 14 system template parameters "%e%p%h%E%s%i%t%c%d%g%I%P%u%%" (e.g., "%p" is 10243 and "%s" is 6). The memory snapshot of process 10243 at this time is its standard input data. When the Linux system responds to the SIGFPE signal, the core dumper core_dumper.sh is run as the root user. Its runtime parameters are the values ​​of the 14 system template parameters "%e%p%h%E%s%i%t%c%d%g%I%P%u%%" (e.g., "%p" is 10360 and "%s" is 8). The memory snapshot of process 10360 at this time is its standard input data. When the Linux system responds to the SIGILL signal, the core dumper core_dumper.sh is run as the root user. The values ​​of the 14 system template parameters "%e%p%h%E%s%i%t%c%d%g%I%P%u%%" (e.g., the value of "%p" is 10361 and the value of "%s" is 4) are its running parameters. The memory snapshot of process 10361 at this time is its standard input data.

[0082] Table 5

[0083]

[0084]

[0085]

[0086] When generating a core file, the generalized template parsing algorithm is first used to parse the generalized template to obtain the path and filename of the core file. This algorithm consists of two parts: matching the core file template and parsing the generalized template parameters of the core file template.

[0087] When matching core file templates, the path and filename of the process's executable file are compared with the key values ​​in the process-specific core file template `executable_core_pattern`. If a match is found, the value corresponding to the key is used as the core file template and the matching ends. If no match is found, the filename of the process's executable file is compared with the key values ​​in `executable_core_pattern`. If a match is found, the value corresponding to the key is used as the core file template and the matching ends. If no match is found, a fuzzy comparison is performed on the filename of the process's executable file with the key values ​​in `executable_core_pattern` that contain wildcards "*" (i.e., whether the filename of the process's executable file is an instance of a certain key value). If a match is found, the value corresponding to the key is used as the core file template and the matching ends. If no match is found, the value of the process-wide core file template `core_pattern` is used as the core file template.

[0088] The core file template matching processes for processes 10219, 10243, 10360, and 10361 are performed using the following methods:

[0089] For process 10219, perform an equality comparison between " / home / zhoucun / shoppingserver" and the key value in executable_core_pattern. If found, take the value " / home / zhoucun / coredump2 / core_%n_^[a-zA-Z0-9]+\-[0-9]+\-[0-9]+\-[0-9]+^_%p_%h_%T" corresponding to " / home / zhoucun / shoppingserver" as the core file template.

[0090] For process 10243, the file " / home / zhoucun / gameserver / 1.1.123567.1 / gameserver-release" is compared with the key value in executable_core_pattern for equality. If no match is found, gameserver-release is compared with the key value in executable_core_pattern for equality. If a match is found, the value corresponding to gameserver-release, " / home / zhoucun / coredump4 / core%C_n%_^[0-9]+\.[0-9]+\.[0-9]+^_^(?<=sceneid=)([0-9]+)(?=)^_%h_%p_%T", is taken as the core file template.

[0091] For process 10360, a comparison is performed between " / home / zhoucun / gameserver / 3.1.35678.2 / gameserver-test" and the key value in executable_core_pattern. If no match is found, a comparison is performed between gameserver-test and the key value in executable_core_pattern. If no match is found, a fuzzy comparison is performed between gameserver-test and the key value in executable_core_pattern containing the wildcard "*". If a match is found, the corresponding value " / home / zhoucun / coredump5 / core_%n_^[0-9]+\.[0-9]+\.[0-9]+^_^(?<=sceneid=)([0-9]+)(?=)^_%h_%p_%T" is taken as the core file template.

[0092] For process 10361, perform an equality comparison between " / home / zhoucun / testserver / testserver" and the key value in executable_core_pattern. If no match is found, perform an equality comparison between testserver and the key value in executable_core_pattern. If no match is found, perform a fuzzy comparison between testserver and the key value in executable_core_pattern that contains the wildcard "*". If no match is found, take the value of the common template core_pattern "core_%n_%p_%h_%T" as the core file template.

[0093] After determining the core file template, the generalized template parameters of the core file template are parsed to obtain the path and filename of the core file. The parsing process is as follows: parsing the template parameters of the Linux system, parsing the extended template parameters "%n,%T,%U", parsing the extended template parameter "%C", and parsing the extended RE template parameters.

[0094] (1) Parsing template parameters of the Linux system

[0095] Perform operations on each of the 14 core file template parameters of the Linux system: search the core file template to see if it contains the specified template parameter, and if it does, replace the specified template parameter in the core file template with its corresponding value.

[0096] (2) Parse the extended template parameter "%n,%T,%U"

[0097] Perform operations on each of the extended core file template parameters "%n,%T,%U": search the core file template to see if it contains the specified template parameter, and if it does, replace the specified template parameter in the core file template with its corresponding value.

[0098] (3) Parse the extended template parameter "%C"

[0099] Search the core file template for the template parameter "%C". If it is found, replace "%C" in the core file template with an empty string and mark the value of the soft limit on the core file size of the process to be ignored.

[0100] (4) Parse the extended RE template parameters

[0101] The process is repeated iteratively: The core file template is searched using the regular expression "\^.*?\^". If the search result is empty, it means the core file template has no RE template parameter, and therefore no generalized template parameter, so the loop ends. If the search result is not empty, it means the core file template has a RE template parameter, and the first result is taken as the target RE template parameter. The regular expression between the prefix and suffix characters "^" of the target RE template parameter is extracted and used to perform a regular expression search on the process startup command line. The first result is used to replace the target RE template parameter in the core file template.

[0102] The generalized template parameter parsing processes for the core file templates matched in processes 10219, 10243, 10360, and 10361 are as follows: Figure 3 , Figure 4 , Figure 5 and Figure 6As shown in the image. Note that the value of "%h" is not explicitly displayed; "hostname-sample" is a substitute for its actual value.

[0103] like Figure 2 As shown, the core dump parses the generalized template to obtain the path and filename of the core file, and then switches from the current root user to the process-starting user. The core file generation process, executed by the process-starting user, proceeds as follows: It navigates to the directory containing the process's executable file; extracts the directory containing the core file from the path and filename, creating it if it doesn't exist; if the value for ignoring the process's soft limit on core file size is not marked, it runs the "head -c" command to overwrite the specified number of bytes of standard input data (the process's soft limit on core file size, i.e., the value corresponding to the system template parameter "%c") into the core file corresponding to the path and filename of the core file; otherwise, it runs the cat command to overwrite the standard input data into the core file corresponding to the path and filename of the core file. If the path and filename of the core file is an absolute path and filename, the core file is generated in the absolute path; if the path and filename of the core file is a relative path and filename, the core file is generated in "the directory containing the process's executable file / relative path"; if the path and filename of the core file is only a filename, the core file is generated in the directory containing the process's executable file.

[0104] For example, the core dumper generates the core files shown below based on the path and filename of the core files of the aforementioned processes 10219, 10243, 10360 and 10361 (where "*" represents partially hidden content, and its content and number do not represent any meaning).

[0105] zhoucun@*****:~$ls -lt / home / zhoucun / coredump2total 379280

[0106] -rw-r--r--1zhoucun zhoucun 388382720 October 9 20:04core_shoppingserver_fruit2-1-8-1_10219_s*****t_20221009200439301082222

[0107] zhoucun@*****:~$ls -lt / home / zhoucun / coredump4total 281624

[0108] -rw-r—r--1zhoucun zhoucun 288382976 October 9 20:04core_gameserver-release_1.1.123456.1_198614399_s****t_10243_20221009200455567033027

[0109] zhoucun@*****:~$ls -lt / home / zhoucun / coredump5total 349984

[0110] -rw-r--r--1zhoucun zhoucun 358383616 October 9 20:05core_gameserver-test_3.1.345678.2_387615391_s*****t_10360_20221009200511661832693

[0111] zhoucun@*****:~$ls -lt / home / zhoucun / testserver total 183988

[0112] -rw-r--r--1zhoucun zhoucun 188383232 October 9 20:05core_testserver_10361_s*****t_20221009200525208743199

[0113] This invention designs a generalized template and generalized template parameters for core files, enabling the definition of both process-wide common core file templates and process-specific core file templates. The above embodiments provide a core dumper that includes a generalized template definition and a generalized template parsing algorithm, employing a technique of pipering process memory snapshots to the core dumper. In the above embodiments, the Linux system automatically runs the core dumper when responding to a core dump signal. The core dumper generates the path and filename of the core file based on the generalized template definition and the generalized template parsing algorithm, and then writes the target process memory snapshot into the core file. Since the generalized template of the core dumper consists of a process-wide common core file template, a process-specific core file template, and generalized template parameters, the generated core file's path and filename can represent both the common characteristics of the process represented by the generalized template parameters and the personalized characteristics of the process represented by the generalized template parameters. This invention extends the Linux system's core file template parameters, providing better feature support, where the RE template parameter enables the extraction of process-specific characteristics.

[0114] It is worth noting that:

[0115] (1) The above settings transmit the process memory snapshot to the core dumper via a pipe. Alternatively, you can first grant executable permissions to " / xx / core_dumper.sh" and then directly execute " / xx / core_dumper.sh". For example, set the content of the Linux system file " / proc / sys / kernel / core_pattern" to "| / xx / core_dumper.sh%e%p%h%E%s%i%t%c%d%g%I%P%u%%". Here, "xx" represents any directory, and core_dumper.sh is the core dumper.

[0116] (2) The definition of the key for the process-specific core file template executable_core_pattern mentioned above can also take other forms depending on different needs. However, if the definition of the key for executable_core_pattern changes, the algorithm for matching the core file template mentioned above also needs to be adapted accordingly.

[0117] (3) The extended core file template parameters listed in Table 4 above can also be redesigned and the generalized template definition of the core dumper and the generalized template parameter parsing algorithm of the core file template can be changed simultaneously as needed.

[0118] (4) The process startup command line mentioned above can be the result of running the command "ps -p process id -o cmd=", or it can be replaced with the string "absolute path filename of the process's executable file process startup parameters" or other strings as needed.

[0119] (5) The above-mentioned method of replacing the target RE template parameter in the core file template with the first one in the regular expression matching search results can also be used to replace the target RE template parameter in the core file template with a non-first one as needed.

[0120] See Figure 7 As shown, this embodiment of the invention provides a core dump file generation apparatus, which includes:

[0121] The memory snapshot and basic core dump information acquisition module 702 is used to respond to a core dump event for the target process and acquire the memory snapshot and basic core dump information of the target process.

[0122] The target core dump parameter template determination module 704 is used to determine the target core dump parameter template corresponding to the target process based on multiple preset core dump parameter templates and basic core dump information; wherein, the core dump parameter template includes multiple core dump parameters; the core dump parameters are used to characterize the basic characteristics or real-time scene characteristics of the target process;

[0123] The storage parameter determination module 706 is used to determine the storage parameters of the core dump file of the target process based on the target core dump parameter template and the basic core dump information.

[0124] The file generation module 708 is used to generate a core dump file of the target process based on storage parameters and memory snapshots.

[0125] The aforementioned core dump file generation device responds to a core dump event targeting a target process by acquiring a memory snapshot and basic core dump information of the target process; based on multiple preset core dump parameter templates and the basic core dump information, it determines the target core dump parameter template corresponding to the target process; wherein, the core dump parameter template includes multiple core dump parameters; the core dump parameters are used to: characterize the basic characteristics or real-time scenario characteristics of the target process; based on the target core dump parameter template and the basic core dump information, it determines the storage parameters of the core dump file of the target process; and based on the storage parameters and the memory snapshot, it generates the core dump file of the target process. In this method, the parameters in the target core dump parameter template can characterize the basic characteristics and real-time scenario characteristics of the target process. Therefore, by using the storage parameters generated based on this template, the process execution scenario and related services provided by the core dump file can be quickly identified, improving the efficiency of identifying and analyzing the core dump file of the target process.

[0126] The aforementioned target core dump parameter template determination module is also used to: extract executable file information of the target process from the basic core dump information; and determine the target core dump parameter template corresponding to the target process based on multiple preset core dump parameter templates and the basic core dump information.

[0127] The aforementioned multiple core dump parameter templates include at least one extended parameter template corresponding to the set executable file information; the aforementioned target core dump parameter template determination module is further used to: match the executable file information of the target process with the set executable file information corresponding to at least one extended parameter template to obtain a matching result; and determine the target core dump parameter template corresponding to the target process based on the matching result.

[0128] The aforementioned executable file information includes setting file storage information and a first set filename or fuzzy filename; file storage information includes a set storage path and a second set filename stored in the set storage path; executable file information includes the storage path and filename of the executable file; extended parameter templates include multiple templates; the aforementioned target core dump parameter template determination module is further used to: perform a first equality comparison search on the setting file storage information corresponding to at least one first extended parameter template among multiple extended parameter templates based on the storage path and filename of the executable file of the target process; if the result of the first equality comparison search is not empty, the matching result is determined to be: the target process matches the retrieved first extended parameter template ... If the result is empty, based on the filename of the executable file of the target process, a second equality comparison search is performed on the first set filename corresponding to at least one second extended parameter template among multiple extended parameter templates; if the result of the second equality comparison search is not empty, the matching result is determined to be: the target process matches the retrieved second extended parameter template; if the result of the second equality comparison search is empty, based on the filename of the executable file of the target process, a fuzzy comparison search is performed on the fuzzy filename corresponding to at least one third extended parameter template among multiple extended parameter templates; if the result of the fuzzy comparison search is not empty, the matching result is determined to be: the target process matches the retrieved third extended parameter template; if the result of the fuzzy comparison search is empty, the matching result is determined to be empty.

[0129] The aforementioned core dump parameter template also includes a common template; the common template includes multiple preset core dump parameters; the aforementioned target core dump parameter template determination module is further used to: if the matching result is that the target process matches the target extended parameter template among the multiple extended parameter templates, determine the target extended parameter template as the target core dump parameter template corresponding to the target process; if the matching result is empty, determine the common template as the target core dump parameter template corresponding to the target process.

[0130] The aforementioned storage parameter determination module is used to: for each target core dump parameter in the target core dump parameter template, obtain the parameter value corresponding to the target core dump parameter from the basic core dump information, or generate the parameter value corresponding to the target core dump parameter based on the basic core dump information; and generate the storage parameters of the core dump file of the target process based on the preset algorithm and the parameter value of the target core dump parameter corresponding to the target process.

[0131] The above storage parameters include the target storage path and the target file name; the file generation module is also used to: generate a first file based on the target storage path and file name; the content of the first file is empty; write the obtained memory snapshot of the target process into the first file, and determine the first file storing the memory snapshot as the core dump file of the target process.

[0132] This embodiment also provides an electronic device, including a processor and a memory. The memory stores machine-executable instructions that can be executed by the processor. The processor executes the machine-executable instructions to implement the above-described method for generating a core dump file. Specifically:

[0133] In response to a core dump event targeting a target process, the system obtains a memory snapshot and basic core dump information of the target process. Based on multiple preset core dump parameter templates and the basic core dump information, it determines the target core dump parameter template corresponding to the target process. The core dump parameter template includes multiple core dump parameters. The core dump parameters are used to characterize the basic features or real-time scene features of the target process. Based on the target core dump parameter template and the basic core dump information, the system determines the storage parameters of the core dump file of the target process. Based on the storage parameters and the memory snapshot, the system generates the core dump file of the target process.

[0134] In the above-mentioned method for generating core dump files, the parameters in the target core dump parameter template can characterize the basic features and real-time scenario features of the target process. Therefore, by generating storage parameters based on this template, the process execution scenario and related services provided by the core dump file can be quickly identified, thereby improving the efficiency of identifying and analyzing the core dump file of the target process.

[0135] Optionally, the step of determining the target core dump parameter template corresponding to the target process based on multiple preset core dump parameter templates and basic core dump information includes: extracting the executable file information of the target process from the basic core dump information; and determining the target core dump parameter template corresponding to the target process based on multiple preset core dump parameter templates and basic core dump information.

[0136] Optionally, the aforementioned multiple core dump parameter templates include at least one extended parameter template corresponding to the set executable file information; the step of determining the target core dump parameter template corresponding to the target process based on the preset multiple core dump parameter templates and basic core dump information includes: matching the executable file information of the target process with the set executable file information corresponding to at least one extended parameter template to obtain a matching result; and determining the target core dump parameter template corresponding to the target process based on the matching result.

[0137] Optionally, the above-mentioned executable file information includes setting file storage information, a first set file name, or an fuzzy file name; the file storage information includes a set storage path and a second set file name stored in the set storage path; the executable file information includes the storage path and file name of the executable file; the extended parameter template includes multiple templates; the step of matching the executable file information of the target process with at least one extended parameter template to obtain a matching result includes: based on the storage path and file name of the executable file of the target process, performing a first equality comparison search on the setting file storage information corresponding to at least one first extended parameter template among the multiple extended parameter templates; if the result of the first equality comparison search is not empty, the matching result is determined to be: the target process matches the retrieved first extended parameter template; If the result of the first equality comparison search is empty, a second equality comparison search is performed on the first set filename corresponding to at least one second extended parameter template among multiple extended parameter templates, based on the filename of the executable file of the target process; if the result of the second equality comparison search is not empty, the matching result is determined to be: the target process matches the retrieved second extended parameter template; if the result of the second equality comparison search is empty, a fuzzy comparison search is performed on the fuzzy filename corresponding to at least one third extended parameter template among multiple extended parameter templates, based on the filename of the executable file of the target process; if the result of the fuzzy comparison search is not empty, the matching result is determined to be: the target process matches the retrieved third extended parameter template; if the result of the fuzzy comparison search is empty, the matching result is determined to be empty.

[0138] Optionally, the aforementioned core dump parameter template also includes a common template; the common template includes multiple preset core dump parameters; the step of determining the target core dump parameter template corresponding to the target process based on the matching result includes: if the matching result is that the target process matches the target extended parameter template among the multiple extended parameter templates, the target extended parameter template is determined as the target core dump parameter template corresponding to the target process; if the matching result is empty, the common template is determined as the target core dump parameter template corresponding to the target process.

[0139] Optionally, the aforementioned target core dump parameter template includes multiple target core dump parameters; the step of determining the storage parameters of the target process's core dump file based on the target core dump parameter template and basic core dump information includes: for each target core dump parameter in the target core dump parameter template, obtaining the parameter value corresponding to the target core dump parameter from the basic core dump information, or generating the parameter value corresponding to the target core dump parameter based on the basic core dump information; and generating the storage parameters of the target process's core dump file based on a preset algorithm and the parameter values ​​of the target core dump parameters corresponding to the target process.

[0140] Optionally, the above storage parameters include the target storage path and the target file name; the step of generating the core dump file of the target process based on the storage parameters and the memory snapshot includes: generating a first file based on the target storage path and the file name, the content of the first file being empty; writing the obtained memory snapshot of the target process into the first file, and determining the first file storing the memory snapshot as the core dump file of the target process.

[0141] See Figure 8 As shown, the electronic device includes a processor 100 and a memory 101. The memory 101 stores machine-executable instructions that can be executed by the processor 100. The processor 100 executes the machine-executable instructions to implement the above-described method for generating a core dump file.

[0142] Furthermore, Figure 8 The electronic device shown also includes a bus 102 and a communication interface 103, with the processor 100, the communication interface 103 and the memory 101 connected via the bus 102.

[0143] The memory 101 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 103 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network. The bus 102 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 8 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0144] Processor 100 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 100 or by instructions in software form. Processor 100 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 101, and the processor 100 reads the information from memory 101 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.

[0145] This embodiment also provides a machine-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and executed by the processor, the machine-executable instructions cause the processor to implement the above-described method for generating the core dump file.

[0146] The present invention provides a method, apparatus, and electronic device for generating a core dump file, comprising a computer-readable storage medium storing program code, wherein the program code includes instructions that can be used to execute the methods described in the preceding method embodiments. Specifically, as follows:

[0147] In response to a core dump event targeting a target process, the system obtains a memory snapshot and basic core dump information of the target process. Based on multiple preset core dump parameter templates and the basic core dump information, it determines the target core dump parameter template corresponding to the target process. The core dump parameter template includes multiple core dump parameters. The core dump parameters are used to characterize the basic features or real-time scene features of the target process. Based on the target core dump parameter template and the basic core dump information, the system determines the storage parameters of the core dump file of the target process. Based on the storage parameters and the memory snapshot, the system generates the core dump file of the target process.

[0148] In the above-mentioned method for generating core dump files, the parameters in the target core dump parameter template can characterize the basic features and real-time scenario features of the target process. Therefore, by generating storage parameters based on this template, the process execution scenario and related services provided by the core dump file can be quickly identified, thereby improving the efficiency of identifying and analyzing the core dump file of the target process.

[0149] Optionally, the step of determining the target core dump parameter template corresponding to the target process based on multiple preset core dump parameter templates and basic core dump information includes: extracting the executable file information of the target process from the basic core dump information; and determining the target core dump parameter template corresponding to the target process based on multiple preset core dump parameter templates and basic core dump information.

[0150] Optionally, the aforementioned multiple core dump parameter templates include at least one extended parameter template corresponding to the set executable file information; the step of determining the target core dump parameter template corresponding to the target process based on the preset multiple core dump parameter templates and basic core dump information includes: matching the executable file information of the target process with the set executable file information corresponding to at least one extended parameter template to obtain a matching result; and determining the target core dump parameter template corresponding to the target process based on the matching result.

[0151] Optionally, the above-mentioned executable file information settings include setting file storage information, a first set file name or an fuzzy file name; file storage information includes setting storage path and a second set file name stored in the set storage path; executable file information includes the storage path and file name of the executable file; extended parameter templates include multiple ones. The step of matching the executable file information of the target process with at least one extended parameter template to obtain a matching result includes: performing a first equality comparison search on the storage information of the set file corresponding to at least one first extended parameter template among multiple extended parameter templates based on the storage path and filename of the executable file of the target process; if the result of the first equality comparison search is not empty, determining the matching result as: the target process matches the retrieved first extended parameter template; if the result of the first equality comparison search is empty, performing a second equality comparison search on the first set filename corresponding to at least one second extended parameter template among multiple extended parameter templates based on the filename of the executable file of the target process; if the result of the second equality comparison search is not empty, determining the matching result as: the target process matches the retrieved second extended parameter template; if the result of the second equality comparison search is empty, performing a fuzzy comparison search on the fuzzy filename corresponding to at least one third extended parameter template among multiple extended parameter templates based on the filename of the executable file of the target process; if the result of the fuzzy comparison search is not empty, determining the matching result as: the target process matches the retrieved third extended parameter template; if the result of the fuzzy comparison search is empty, determining the matching result as empty.

[0152] Optionally, the aforementioned core dump parameter template also includes a common template; the common template includes multiple preset core dump parameters; the step of determining the target core dump parameter template corresponding to the target process based on the matching result includes: if the matching result is that the target process matches the target extended parameter template among the multiple extended parameter templates, the target extended parameter template is determined as the target core dump parameter template corresponding to the target process; if the matching result is empty, the common template is determined as the target core dump parameter template corresponding to the target process.

[0153] Optionally, the aforementioned target core dump parameter template includes multiple target core dump parameters; the step of determining the storage parameters of the target process's core dump file based on the target core dump parameter template and basic core dump information includes: for each target core dump parameter in the target core dump parameter template, obtaining the parameter value corresponding to the target core dump parameter from the basic core dump information, or generating the parameter value corresponding to the target core dump parameter based on the basic core dump information; and generating the storage parameters of the target process's core dump file based on a preset algorithm and the parameter values ​​of the target core dump parameters corresponding to the target process.

[0154] Optionally, the above storage parameters include the target storage path and the target file name; the step of generating the core dump file of the target process based on the storage parameters and the memory snapshot includes: generating a first file based on the target storage path and the file name; writing the obtained memory snapshot of the target process into the first file; and determining the first file storing the memory snapshot as the core dump file of the target process.

[0155] See Figure 8 As shown, the electronic device includes a processor 100 and a memory 101. The memory 101 stores machine-executable instructions that can be executed by the processor 100. The processor 100 executes the machine-executable instructions to implement the above-described method for generating a core dump file.

[0156] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0157] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention according to the specific circumstances.

[0158] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0159] In the description of this invention, it should be noted that the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0160] Finally, it should be noted that the above embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A method for generating a core dump file, characterized in that, include: In response to a core dump event targeting a target process, obtain a memory snapshot and basic core dump information of the target process; Based on multiple preset core dump parameter templates and the basic core dump information, a target core dump parameter template corresponding to the target process is determined; wherein, the core dump parameter template includes multiple core dump parameters; the core dump parameters are used to characterize the basic characteristics or real-time scene characteristics of the target process; Based on the target core dump parameter template and the basic core dump information, the storage parameters of the core dump file of the target process are determined; Based on the storage parameters and the memory snapshot, a core dump file of the target process is generated; The multiple core dump parameter templates include at least one extended parameter template corresponding to the set executable file information; The step of determining the target core dump parameter template corresponding to the target process based on multiple preset core dump parameter templates and the basic core dump information includes: Extract the executable file information of the target process from the basic core dump information; The executable file information of the target process is matched with the set executable file information corresponding to at least one of the extended parameter templates to obtain a matching result; Based on the matching results, the target core dump parameter template corresponding to the target process is determined.

2. The method according to claim 1, characterized in that, The executable file information includes setting file storage information and a first set filename or an fuzzy filename; the file storage information includes a set storage path and a second set filename stored in the set storage path; the executable file information includes the storage path and filename of the executable file; the extended parameter template includes multiple templates; The step of matching the executable file information of the target process with at least one of the extended parameter templates to obtain a matching result includes: Based on the storage path and filename of the executable file of the target process, a first equality comparison retrieval is performed on the setting file storage information corresponding to at least one of the multiple extended parameter templates; If the result of the first equality comparison search is not empty, the matching result is determined to be: the target process matches the retrieved first extended parameter template; If the result of the first equality comparison search is empty, a second equality comparison search is performed on the first set filename corresponding to at least one of the multiple extended parameter templates based on the filename of the executable file of the target process; If the result of the second equality comparison search is not empty, the matching result is determined to be: the target process matches the retrieved second extended parameter template; If the result of the second equality comparison search is empty, based on the filename of the executable file of the target process, perform a fuzzy comparison search on the fuzzy filename corresponding to at least one of the third extended parameter templates among the multiple extended parameter templates; If the result of the fuzzy comparison search is not empty, the matching result is determined to be: the target process matches the retrieved third extended parameter template; If the result of the fuzzy comparison search is empty, the matching result is determined to be empty.

3. The method according to claim 1, characterized in that, The multiple core dump parameter templates also include a common template; the common template includes multiple preset core dump parameters; Based on the matching results, the step of determining the target core dump parameter template corresponding to the target process includes: If the matching result is that the target process matches the target extended parameter template among the multiple extended parameter templates, the target extended parameter template is determined as the target core dump parameter template corresponding to the target process; If the matching result is empty, the common template is determined as the target core dump parameter template corresponding to the target process.

4. The method according to claim 1, characterized in that, The target core dump parameter template includes multiple target core dump parameters; The step of determining the storage parameters of the core dump file of the target process based on the target core dump parameter template and the basic core dump information includes: For each target core dump parameter in the target core dump parameter template, obtain the parameter value corresponding to the target core dump parameter from the basic core dump information, or generate the parameter value corresponding to the target core dump parameter based on the basic core dump information; Based on the preset algorithm and the parameter values ​​of the target core dump parameters corresponding to the target process, the storage parameters of the core dump file of the target process are generated.

5. The method according to claim 1, characterized in that, The storage parameters include the target storage path and the target file name; The step of generating the core dump file of the target process based on the storage parameters and the memory snapshot includes: A first file is generated based on the target storage path and the file name; the content of the first file is empty. The obtained memory snapshot of the target process is written to the first file, and the first file storing the memory snapshot is determined as the core dump file of the target process.

6. A device for generating a core dump file, characterized in that, include: The memory snapshot and basic core dump information acquisition module is used to respond to a core dump event for a target process and acquire the memory snapshot and basic core dump information of the target process. The target core dump parameter template determination module is used to determine the target core dump parameter template corresponding to the target process based on multiple preset core dump parameter templates and the basic core dump information; wherein, the core dump parameter template includes multiple core dump parameters; the core dump parameters are used to characterize the basic characteristics or real-time scene characteristics of the target process; The storage parameter determination module is used to determine the storage parameters of the core dump file of the target process based on the target core dump parameter template and the basic core dump information. The file generation module is used to generate the core dump file of the target process based on the storage parameters and the memory snapshot; The multiple core dump parameter templates include at least one extended parameter template corresponding to the set executable file information; The target core dump parameter template determination module is also used for: Extract the executable file information of the target process from the basic core dump information; The executable file information of the target process is matched with the set executable file information corresponding to at least one of the extended parameter templates to obtain a matching result; Based on the matching results, the target core dump parameter template corresponding to the target process is determined.

7. An electronic device, characterized in that, The system includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the method for generating a core dump file as described in any one of claims 1-5.

8. A machine-readable storage medium, characterized in that, The machine-readable storage medium stores machine-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the method for generating a core dump file as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Core dump file generation method, computing device and storage medium

    CN113553211A

  • Core dump file generation method and device, electronic equipment and storage medium

    CN115391077A