CN115617521A - Method, device and medium for receiving application process memory snapshot - Google Patents

Method, device and medium for receiving application process memory snapshot Download PDF

Info

Publication number
CN115617521A
CN115617521A CN202211296496.2A CN202211296496A CN115617521A CN 115617521 A CN115617521 A CN 115617521A CN 202211296496 A CN202211296496 A CN 202211296496A CN 115617521 A CN115617521 A CN 115617521A
Authority
CN
China
Prior art keywords
memory
vma
address space
information
calling
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211296496.2A
Other languages
Chinese (zh)
Inventor
李辉
孙明刚
刘清林
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Mass Institute Of Information Technology
Original Assignee
Inspur Electronic Information Industry Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Electronic Information Industry Co Ltd filed Critical Inspur Electronic Information Industry Co Ltd
Priority to CN202211296496.2A priority Critical patent/CN115617521A/en
Publication of CN115617521A publication Critical patent/CN115617521A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Abstract

The invention provides a method, a device and a medium for receiving application process memory snapshots, which are suitable for the technical field of process management. Initiating a memory snapshot instruction by a daemon process after the business process exits; calling a control word through a service process to reserve the memory of the service process; traversing the vma information in the address space corresponding to the service process through the daemon process; and performing memory mapping according to the vma information to obtain an address space of the service process and transferring the address space to a file. And the memory of the business process is saved by driving the control word when the business process exits, so that the system can conveniently recover the address space of the current business process and save the address space into a file to realize memory snapshot. The method and the device avoid the problems that the prior memory snapshot is limited in a specific scene (meets a certain trigger condition) effectively and the debugging process is influenced due to the fact that the memory snapshot file is received incompletely, improve the universality of the scene for obtaining the memory snapshot, are suitable for various scenes, and improve the debugging efficiency.

Description

Method, device and medium for receiving application process memory snapshot
Technical Field
The present invention relates to the technical field of process management, and in particular, to a method, an apparatus, and a medium for receiving an application process memory snapshot.
Background
When an abnormal termination or crash state occurs in the process of program running, the operating system records and saves the current memory state of the program into a file, similar to a memory snapshot (core dump), the core dump is important for a programmer to diagnose and debug the program, and for some program errors, it is difficult to reproduce (for example, a pointer exception) a scenario in which the program error can be online through the core dump file.
For the core dump mechanism, the method can be effectively reproduced only under a specific scene, for example, a memory snapshot can be received when the configuration condition of the core dump is met, the signal trigger condition (pause process (Stop), terminate process (Terminate), terminate and generate the core dump (core), and the like). In the scene that the memory snapshot is not received, no debugging basis is available for reference in the debugging process; or the file possibly received in the receiving process is incomplete, so that the debugging process is influenced, and the debugging result is directly influenced.
Therefore, a need in the art to solve how to collect application process memory snapshots in various scenarios to improve generality needs to be addressed.
Disclosure of Invention
The invention aims to provide a method, a device and a medium for receiving memory snapshots of an application process, which improve the scene universality of the memory snapshots, are suitable for various scenes and improve the debugging efficiency.
In order to solve the above technical problem, the present invention provides a method for receiving an application process memory snapshot, including:
establishing a daemon process, and initiating a memory snapshot instruction by the daemon process after the business process exits;
calling a control word through the business process to reserve the memory of the business process;
traversing the vma information in the address space corresponding to the service process through the daemon process;
and performing memory mapping according to the vma information to obtain an address space of the business process and transferring the address space to a file.
Preferably, the control word is obtained by presetting a registration character device and calling the registration character device.
Preferably, the invoking a control word through the business process to reserve the memory of the business process includes:
calling the control word in the registration character device;
correspondingly, invoking the control word comprises:
calling a get _ task _ mm instruction;
and returning the get _ task _ mm instruction according to the calling to give a control handle.
Preferably, the traversing, by the daemon, the vma information in the address space corresponding to the business process includes:
and traversing the mmap chain table header in the data structure to which the address space of the service process belongs to obtain the vma information.
Preferably, after traversing the vma information in the address space corresponding to the business process by the daemon process, before performing memory mapping according to the vma information, the method further includes:
saving the vma information;
after the business process exits, calling the control word to ask for a vma list from a kernel through the daemon process;
returning the vma list to user space.
Preferably, the performing memory mapping according to the vma information to obtain an address space of the service process includes:
and performing mmap memory mapping according to the vma information and the vma list to obtain the address space.
Preferably, after the unloading to the file, the method further comprises:
and initiating a disable resident instruction through the register character device to release the memory.
In order to solve the above technical problem, the present invention further provides a device for receiving an application process memory snapshot, including:
the establishing module is used for establishing a daemon process and initiating a memory snapshot instruction by the daemon process after the business process exits;
the calling module is used for calling the control word through the business process so as to reserve the memory of the business process;
the traversal module is used for traversing the vma information in the address space corresponding to the business process through the daemon process;
and the mapping module is used for carrying out memory mapping according to the vma information to obtain an address space of the business process and transferring the address space to a file.
In order to solve the above technical problem, the present invention further provides a device for receiving an application process memory snapshot, including:
a memory for storing a computer program;
and the processor is used for realizing the steps of the method for receiving the memory snapshot of the application process when the computer program is executed.
In order to solve the above technical problem, the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements the steps of the method for collecting the memory snapshot of the application process as described above.
The invention provides a method for receiving application process memory snapshots, which comprises the following steps: establishing a daemon process, and initiating a memory snapshot instruction by the daemon process after the business process exits; calling a control word through a service process to reserve the memory of the service process; traversing the vma information in the address space corresponding to the service process through the daemon process; and performing memory mapping according to the vma information to obtain an address space of the service process and transferring the address space to a file. The method saves the memory of the business process when the business process exits by driving the control word, so that the system can conveniently recover the address space of the current business process and save the address space into a file to realize memory snapshot. The method and the device avoid the problems that the prior memory snapshot is limited in a specific scene (meets a certain trigger condition) effectively and the debugging process is influenced due to the fact that the memory snapshot file is received incompletely, improve the universality of the scene for obtaining the memory snapshot, are suitable for various scenes, and improve the debugging efficiency.
In addition, the invention also provides a device and a medium for receiving the application process memory snapshot, and has the same beneficial effects as the method for receiving the application process memory snapshot.
Drawings
In order to more clearly illustrate the embodiments of the present invention, the drawings required for the embodiments will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained by those skilled in the art without inventive effort.
Fig. 1 is a flowchart of a method for receiving an application process memory snapshot according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating creation of a process address space according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a data structure in a process address space according to an embodiment of the invention;
fig. 4 is a structural diagram of a device for receiving a memory snapshot of an application process according to an embodiment of the present invention;
fig. 5 is a block diagram of another apparatus for receiving a memory snapshot of an application process according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without any creative work belong to the protection scope of the present invention.
The core of the invention is to provide a method, a device and a medium for receiving the memory snapshot of the application process, which improve the scene universality of the memory snapshot, are suitable for various scenes and simultaneously improve the debugging efficiency.
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments.
It should be noted that, a memory snapshot occurs when an existing application program terminates abnormally or crashes in the running process, but the memory snapshot does not occur in all the running processes of the application program, for example, a kill-9 instruction is used to execute an instruction on a process, and the memory snapshot does not occur in the process because a corresponding configuration condition and a trigger condition are not set. Signals in the Linux system are a mechanism for asynchronous event processing, each signal corresponds to a default operation, and the default operation mainly comprises the steps of ignoring the signal (Ingore), suspending a process (Stop), terminating a process (Terminate), terminating and generating a core dump (core) and the like. If the signals are all the default operations, table 1 is a signal table of the default operations, and as shown in table 1, memory snapshots are generated when the signals in the table occur. The method for receiving the memory snapshot of the application process is suitable for the application program of the linux, the application program based on the linux system has various scenes needing debugging,
TABLE 1 signal table for default operation
Figure BDA0003902855800000041
Figure BDA0003902855800000051
Fig. 1 is a flowchart of a method for receiving an application process memory snapshot according to an embodiment of the present invention, as shown in fig. 1, the method includes:
s11: establishing a daemon process, and initiating a memory snapshot instruction by the daemon process after the business process exits;
s12: calling a control word through a service process to reserve the memory of the service process;
s13: traversing vma information in an address space corresponding to the service process through a daemon process;
s14: and performing memory mapping according to the vma information to obtain an address space of the service process and transferring the address space to a file.
Specifically, a daemon process is established, which is responsible for initiating a business process, and is designed for the business process, and the daemon process is used for monitoring the current running state of the business process and initiating the receipt of a memory snapshot instruction after the business process exits.
The memory snapshot records data in a memory at a certain moment, and stores the data in a hard disk in a file form, wherein the data still exist even if the hard disk is down. The data only needs to be restored after the server is restarted. When the core of the program is lost, positioning solution is needed, and most of the description means that the corresponding program is abnormally exited or suspended in the running process due to various exceptions or bugs, and a file called the core is generated under certain conditions.
Generally, a core file includes a memory, a register state, a stack pointer, memory management information, various function call stack information and the like during program operation, which can be understood as a file generated by storing a program in a current working state, a core file is generated when many programs make mistakes, the file is analyzed by a tool, information such as corresponding stack call and the like when the program exits abnormally is located, and the problem is found and solved in time.
By calling the control word by the service process to reserve the memory of the service process, it can be understood that the character device needs to be registered to realize the relevant control word in the process of communicating the application program and the kernel. As an embodiment, the control word is obtained by presetting a registered character device and calling the registered character device.
The character device processes data according to the form of byte stream, and supports sequence method and random access, the typical character device: serial port, keyboard, touch screen, camera, serial bus (I2C), serial Peripheral Interface (SPI), sound card, frame buffer …; sequential access device: a serial port, a keyboard and a touch screen; device of random access: a frame buffer device. The device number facilitates management of an operating system, for example, a Process, facilitates management of the system, and has a Process number, i.e., a Process Identifier (PID), which can be known by using a ps command; the Thread is convenient for system management, and has a Thread number, namely a Thread Identifier (TID), and the Thread id is returned by the created Thread; just as everyone will have a name, but names are easy to be the same name, and this time can be distinguished by using identification number.
A registration character device, the registration step of which:
1. apply for the equipment number for the character equipment, including main equipment number and inferior equipment number:
1. automatically allocating a function of the equipment number by using a kernel;
2. registering a user-defined device number with the kernel;
3. when the module is unloaded, the equipment number is logged out;
2. applying for cdev structural body space from the kernel for describing character equipment;
3. initializing a cdev structural body and initializing an operation function set;
4. registering character equipment with a kernel, wherein count represents the number of registrations;
5. and when unloading is driven, the character cdev structural body is cancelled, and system resources are released.
In this embodiment, the control word is called by calling a control word of an IO control (ioctl), where ioctl is a function of a device driver that manages Input/Output channels (I/O) of a device. The management of the I/O channel is to control some characteristics of the device, such as the transmission baud rate of the serial port, the rotation speed of the motor, and the like. That is, during the driver process, if some IO operations are encountered, and cannot be logically classified as read or write, then it can be considered as part of the ioctl. read and write should be written and read data and should be handled as a pure data exchange. While ioctl controls some options for read and write.
The generic parameter format for Ioctl is the way the command word (constant) + command parameter. The use method comprises the following steps: int ioctl (int handle, int cmd, [ int × argdx, int argcx ]);
parameters are as follows: fd is the file identifier returned by the open function when the user program opens the device, and cmd is the control command of the user program to the device, followed by some supplementary parameters, usually at most one, the presence or absence of which is related to the meaning of cmd.
Control of the I/O channels of the device may also be achieved if ioctl is not used. For example, it may be checked at the time of write implementation in the driver whether a specially agreed data stream passes through at a single moment, and if so, followed by control commands (which is often done in socket programming). However, if this is done, the code division is unclear, the program structure is disordered, and the programmer may be dazzling. So ioctl is used to implement the functionality of the control. What the user program does is just telling the driver what it wants to do through the command code (cmd), which is what the driver does, how to interpret the commands and how to implement them.
And calling the control word through the service process to reserve the memory of the service process, and not allowing the recovery of the operating system. As an embodiment, calling a control word by a business process to reserve a memory of the business process includes:
calling a control word in a registered character device;
correspondingly, the control word is called, including:
calling a get _ task _ mm instruction;
the get _ task _ mm instruction return from the call is given to the control handle.
Specifically, the character device is registered, and the definition name is/dev/plmm. The specific implementation mode is that the service process is completed through ioctl call, i ctl ("/dev/plmm", CMD _ PIN). A CMD _ PIN control word is driven in the character device, which calls the get _ task _ mm (current) command. The get _ task _ mm function describes: the function obtains corresponding memory information according to the provided task descriptor information, and the memory information is stored in the variable of the mm _ struct structure type. The return result of the function is a variable of the structure type of the struct task _ struct, and task descriptor information meeting the conditions is stored. The memory information corresponding to the task descriptor, that is, the memory information corresponding to a certain task, is returned in this embodiment to give a control handle plmm _ dump _ pinedmm.
In step S13, traversing the vma information in the address space corresponding to the service process through the daemon process, and returning the vma information obtained after the traversal to the user space, as an embodiment, the traversing the vma information in the address space corresponding to the service process through the daemon process includes:
and traversing the mmap chain table head in the data structure to which the address space of the business process belongs to obtain the vma information.
It can be understood that, through CMD _ GETMAP of the character device control word, the specific implementation mode traverses the mmap list header in the data structure to which the address space of the service process belongs, and the structure is as follows: plmm _ dump _ pinedmm- > mmap. And after traversing to the current vma space, continuously traversing in the next vma space, and storing the result.
The process address space (process address space) is an address space viewed from the process perspective, and is a set of virtual addresses used when the process is running. The process address space consists of all linear addresses that a process is allowed to use. The set of linear addresses seen by each process is different. The kernel dynamically modifies the address space of a process by adding or deleting certain linear address intervals. Since the kernel needs to distinguish between invalid linear addresses (programming errors) in the user space and valid linear addresses (e.g., page faults caused by a user process accessing the malloc allocated space), it is necessary to determine the linear region currently owned by a process.
Fig. 2 is a schematic diagram illustrating the creation of a process address space according to an embodiment of the present invention, and as shown in fig. 2, for an elf executable file, an exec system call calls load _ elf _ binary to create the process address space. The process address space is divided into a plurality of linear zones, including stack, mmap mapping zone, heap, bss, data segment and text segment, each linear zone is managed corresponding to a vm _ area _ structure, and the vm _ area _ structure sets the access authority and the starting address of the linear zone.
Fig. 3 is a schematic diagram of a data structure in a process address space according to an embodiment of the present invention, as shown in fig. 3, a virtual memory space of a process is divided into a plurality of different areas, each area has its associated attributes and uses, a legal address always falls in a certain area, and the areas do not overlap. In the linux kernel, such a region is called a virtual memory region (vma), for short. A vma is an abstraction of a continuous linear address space that has its own rights (readable, writable, executable, etc.), and each virtual memory region is described by an associated struct vm _ area _ struct structure. A plurality of vma areas of a process are organized together according to a certain form, the vma areas are all contained in a memory descriptor of the process, namely struct mm _ struct, the vma areas are organized in mm _ struct in two modes, one mode is a linked list mode, the vmap linked list head in mm _ struct is corresponded, the other mode is a red and black tree mode, the linked list is corresponded to mm _ rb root nodes in mm _ struct, and the linked list is used for traversing and the red and black tree is used for searching as other places of a kernel. In this embodiment, traversal is required, and a linked list mode is selected to connect linked lists performed in the vma space.
In step S14, memory mapping is performed according to the vma information to obtain an address space of the service process, and since the daemon process reads the address space of the service process after the service process exits, memory mapping needs to be performed on mmap. The mmap memory mapping is a shared memory mapping, and the shared memory is the most useful inter-process communication mode and the fastest IPC (inter process communication) form, because the processes can directly read and write the memory without copying any data. For communication modes such as pipelines and message queues, four data copies need to be made in the kernel and the user space, and the shared memory only copies two data: once from the input file to the shared memory area and once from the shared memory area to the output file. In fact, when the processes share the memory, the mapping is not always released after a small amount of data is read and written, and when new communication exists, the shared memory area is reestablished. But the shared area is maintained until the communication is completed, so that the data content is always stored in the shared memory and is not written back to the file. The contents of the shared memory are often written back to the file when the mapping is removed. Therefore, the communication method using the shared memory is very efficient.
And the Mmap () system calls to enable processes to realize memory sharing by mapping the same common file. After the ordinary file is mapped to the process address space, the process can access the file as accessing the ordinary memory, and operations such as read () and write () do not need to be called.
And obtaining the address space of the business process according to the mapped memory, and transferring the address space to a file to complete the memory snapshot of the current business process. As an embodiment, the performing memory mapping according to the vma information in step S14 to obtain an address space of the service process includes:
and performing mmap memory mapping according to the vma information and the vma list to obtain an address space.
It can be understood that the mmap memory mapping is performed through the vma information in the vma list to obtain the address space, as shown in fig. 2, several vma areas may be organized together in a certain form, and these vmas are all included in the memory descriptor of the process. The vma corresponds to the mmap list head, and the mapped address space after the business process exits can be obtained according to mmap memory mapping, so that the address space of the business process can be obtained.
The method for receiving the memory snapshot of the application process provided by the embodiment of the invention comprises the following steps: establishing a daemon process, and initiating a memory snapshot instruction by the daemon process after the business process exits; calling a control word through a service process to reserve the memory of the service process; traversing the vma information in the address space corresponding to the service process through the daemon process; and performing memory mapping according to the vma information to obtain an address space of the service process and transferring the address space to a file. The method saves the memory of the business process when the business process exits by driving the control word, so that the system can conveniently recover the address space of the current business process and save the address space into a file to realize memory snapshot. The method and the device avoid the problems that the prior memory snapshot is limited in a specific scene (meets a certain trigger condition) effectively and the debugging process is influenced due to the fact that the memory snapshot file is received incompletely, improve the universality of the scene for obtaining the memory snapshot, are suitable for various scenes, and improve the debugging efficiency.
On the basis of the foregoing embodiment, after traversing the vma information in the address space corresponding to the business process by the daemon process in step S13, before performing memory mapping according to the vma information in step S14, the method further includes:
save the vma information;
after the business process exits, calling a control word to ask the kernel for a vma list through a daemon process;
the vma list is returned to user space.
It can be understood that after the service process exits, the daemon calls the relevant control word through the character device, and obtains the traversed vma result information to the vma list to be relevant to the kernel through the ioctl ("/dev/plmm", CMD _ GETMAP) kernel character device so as to return to the user space.
The kernel is called through the character device control word to obtain the traversed vma list, so that the shared memory mapping is conveniently carried out subsequently to read the process address space.
On the basis of the above embodiment, after the transferring to the file, the method further includes:
and initiating a disable resident instruction by the register character device to release the memory.
After the address space of the business process is obtained, the business process is simultaneously transferred to a related file, and the related file initiates a resident enabling instruction through a character device so as to allow an operating system to recycle the address space of the current process. The specific implementation mode is as follows:
calling mmput (plmm _ dump _ pinnedmm)
The kernel is caused to release the exited process page table space by calling ioctl ("/dev/plmm", CMD _ UNPIN).
After the current business process is transferred to the file, the enabling resident instruction is initiated through the character device to release the memory, and the memory is released to save memory resources.
On the basis of the above detailed description of each embodiment corresponding to the method for receiving the memory snapshot of the application process, the present invention further discloses a device for receiving the memory snapshot of the application process corresponding to the above method, and fig. 4 is a structural diagram of the device for receiving the memory snapshot of the application process provided in the embodiment of the present invention. As shown in fig. 4, the apparatus for receiving the memory snapshot of the application process includes:
the establishing module 11 is configured to establish a daemon process, and initiate a memory snapshot instruction by the daemon process after the service process exits;
the calling module 12 is used for calling the control word through the service process so as to reserve the memory of the service process;
the traversal module 13 is configured to traverse, through the daemon process, vma information in the address space corresponding to the service process;
and the mapping module 14 is configured to perform memory mapping according to the vma information to obtain an address space of the service process and forward the address space to a file.
Since the embodiment of the apparatus portion corresponds to the above-mentioned embodiment, the embodiment of the apparatus portion is described with reference to the embodiment of the method portion, and is not described again here.
The device for receiving the memory snapshot of the application process provided by the embodiment of the invention comprises the following steps: establishing a daemon process, and initiating a memory snapshot instruction by the daemon process after the service process exits; calling a control word through a service process to reserve the memory of the service process; traversing vma information in an address space corresponding to the service process through a daemon process; and performing memory mapping according to the vma information to obtain an address space of the service process and transferring the address space to a file. The device saves the memory of the business process when the business process exits through the drive control word, so that the system can conveniently recover the address space of the current business process and save the address space into a file to realize memory snapshot. The method and the device avoid the problems that the prior memory snapshot is limited in a specific scene (meets a certain trigger condition) effectively and the debugging process is influenced due to the fact that the memory snapshot file is received incompletely, improve the universality of the scene for obtaining the memory snapshot, are suitable for various scenes, and improve the debugging efficiency.
Fig. 5 is a block diagram of another apparatus for receiving a memory snapshot of an application process according to an embodiment of the present invention, as shown in fig. 5, the apparatus includes:
a memory 21 for storing a computer program;
the processor 22 is configured to implement the steps of the method for collecting the memory snapshot of the application process when executing the computer program.
The device for collecting the application process memory snapshot provided in this embodiment may include, but is not limited to, a smart phone, a tablet computer, a notebook computer, or a desktop computer.
The processor 22 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and so on. The Processor 22 may be implemented in hardware using at least one of a Digital Signal Processor (DSP), a Field-Programmable Gate Array (FPGA), and a Programmable Logic Array (PLA). The processor 22 may also include a main processor and a coprocessor, the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 22 may be integrated with a Graphics Processing Unit (GPU) that is responsible for rendering and drawing the content that the display screen needs to display. In some embodiments, processor 22 may also include an Artificial Intelligence (AI) processor for processing computational operations related to machine learning.
Memory 21 may include one or more computer-readable storage media, which may be non-transitory. Memory 21 may also include high speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In this embodiment, the storage 21 is at least used for storing the following computer program 211, wherein after the computer program is loaded and executed by the processor 22, the relevant steps of the method for collecting the memory snapshot of the application process disclosed in any of the foregoing embodiments can be implemented. In addition, the resources stored in the memory 21 may also include an operating system 212, data 213, and the like, and the storage manner may be a transient storage or a permanent storage. Operating system 212 may include Windows, unix, linux, etc., among others. Data 213 may include, but is not limited to, data related to methods of taking memory snapshots of an application process, and the like.
In some embodiments, the device for taking the memory snapshot of the application process may further include a display 23, an input/output interface 24, a communication interface 25, a power supply 26, and a communication bus 27.
Those skilled in the art will appreciate that the architecture shown in FIG. 5 does not constitute a limitation on the means for taking memory snapshots of an application process and may include more or fewer components than those shown.
The processor 22 implements the method for taking the memory snapshot of the application process provided in any of the above embodiments by calling the instructions stored in the storage 21.
The device for receiving the memory snapshot of the application process provided by the embodiment of the invention comprises the following steps: establishing a daemon process, and initiating a memory snapshot instruction by the daemon process after the business process exits; calling a control word through a service process to reserve the memory of the service process; traversing vma information in an address space corresponding to the service process through a daemon process; and performing memory mapping according to the vma information to obtain an address space of the business process and transferring the address space to a file. The device saves the memory of the business process when the business process exits through the drive control word, so that the system can conveniently recover the address space of the current business process and save the address space into a file to realize memory snapshot. The method and the device avoid the problems that the prior memory snapshot is limited in a specific scene (meets a certain trigger condition) effectively and the debugging process is influenced due to the fact that the memory snapshot file is received incompletely, improve the universality of the scene for obtaining the memory snapshot, are suitable for various scenes, and improve the debugging efficiency.
Further, the present invention also provides a computer readable storage medium, on which a computer program is stored, and the computer program, when executed by the processor 22, implements the steps of the method for collecting the memory snapshot of the application process.
It is understood that, if the method in the above embodiments is implemented in the form of software functional units and sold or used as a stand-alone product, it can be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and performs all or part of the steps of the methods according to the embodiments of the present invention, or all or part of the technical solution. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
For the introduction of a computer-readable storage medium provided by the present invention, please refer to the above method embodiment, which is not described herein again, and has the same beneficial effect as the above method for receiving the application process memory snapshot.
The method for receiving the application process memory snapshot, the device for receiving the application process memory snapshot and the medium provided by the invention are described in detail above. The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a … …" does not exclude the presence of another identical element in a process, method, article, or apparatus that comprises the element.

Claims (10)

1. A method for receiving memory snapshots of an application process is characterized by comprising the following steps:
establishing a daemon process, and initiating a memory snapshot instruction by the daemon process after the business process exits;
calling a control word through the service process to reserve the memory of the service process;
traversing the vma information in the address space corresponding to the business process through the daemon process;
and performing memory mapping according to the vma information to obtain an address space of the service process and transferring the address space to a file.
2. The method according to claim 1, wherein the control word is obtained by presetting a register character device and calling the register character device.
3. The method of claim 2, wherein the calling a control word by the business process to reserve the memory of the business process comprises:
calling the control word in the registration character device;
correspondingly, calling the control word comprises:
calling a get _ task _ mm instruction;
and returning the get _ task _ mm instruction according to the calling to give a control handle.
4. The method according to claim 3, wherein traversing vma information in an address space corresponding to the business process by the daemon process comprises:
and traversing the mmap chain table head in the data structure to which the address space of the service process belongs to obtain the vma information.
5. The method according to claim 4, wherein after traversing vma information in an address space corresponding to the business process by the daemon process and before performing memory mapping according to the vma information, the method further comprises:
saving the vma information;
after the business process exits, calling the control word to ask for a vma list from a kernel through the daemon process;
returning the vma list to user space.
6. The method according to claim 5, wherein the performing memory mapping according to the vma information to obtain the address space of the service process comprises:
and performing mmap memory mapping according to the vma information and the vma list to obtain the address space.
7. The method according to any one of claims 1 to 6, further comprising, after the transferring to the file:
and initiating a disable resident instruction through the register character device to release the memory.
8. An apparatus for collecting memory snapshots of an application process, comprising:
the establishing module is used for establishing a daemon process and initiating a memory snapshot instruction by the daemon process after the business process exits;
the calling module is used for calling the control word through the service process so as to reserve the memory of the service process;
the traversal module is used for traversing the vma information in the address space corresponding to the business process through the daemon process;
and the mapping module is used for carrying out memory mapping according to the vma information to obtain the address space of the business process and transferring the address space to a file.
9. An apparatus for collecting memory snapshots of an application process, comprising:
a memory for storing a computer program;
a processor adapted to implement the steps of the method of collecting memory snapshots of an application process according to any one of claims 1 to 7 when the computer program is executed.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the method of collecting memory snapshots of an application process according to any one of claims 1 to 7.
CN202211296496.2A 2022-10-21 2022-10-21 Method, device and medium for receiving application process memory snapshot Pending CN115617521A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211296496.2A CN115617521A (en) 2022-10-21 2022-10-21 Method, device and medium for receiving application process memory snapshot

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211296496.2A CN115617521A (en) 2022-10-21 2022-10-21 Method, device and medium for receiving application process memory snapshot

Publications (1)

Publication Number Publication Date
CN115617521A true CN115617521A (en) 2023-01-17

Family

ID=84864352

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211296496.2A Pending CN115617521A (en) 2022-10-21 2022-10-21 Method, device and medium for receiving application process memory snapshot

Country Status (1)

Country Link
CN (1) CN115617521A (en)

Similar Documents

Publication Publication Date Title
US6275893B1 (en) Method and apparatus for providing seamless hooking and intercepting of selected kernel and HAL exported entry points in an operating system
CN105446806B (en) A kind of processing method and processing device of the application program without response
US6698016B1 (en) Method for injecting code into another process
US11620215B2 (en) Multi-threaded pause-less replicating garbage collection
CN103942178A (en) Communication method between real-time operating system and non-real-time operating system on multi-core processor
CN113918101B (en) Method, system, equipment and storage medium for writing data cache
CN109491759B (en) Process debugging method and device based on virtual file system and computer equipment
CN111897666A (en) Method, device and system for communication among multiple processes
CN112306669A (en) Task processing method and device based on multi-core system
US20190227918A1 (en) Method for allocating memory resources, chip and non-transitory readable medium
CN113467964A (en) Method, system, device and storage medium for realizing access to user mode protocol stack
WO2021174698A1 (en) Virtual machine snapshot creation method and apparatus, and storage medium and computer device
US7418714B2 (en) Employing three parameter buffer access in connection with SMBus notifications
WO2022032990A1 (en) Command information transmission method, system, and apparatus, and readable storage medium
CN115617521A (en) Method, device and medium for receiving application process memory snapshot
CN111865978A (en) Method, device, equipment and medium for updating request identifier of micro-service
WO2023240941A1 (en) Method and apparatus for downloading data, and secure element
WO2022242665A1 (en) Data storage method and related device
CN108198582B (en) NAND Flash control method and device and SSD
CN111522764B (en) Plug-in operation processing method, terminal and storage medium
CN115033337A (en) Virtual machine memory migration method, device, equipment and storage medium
US7336664B2 (en) Data processing device and its input/output method and program
CN100492299C (en) Embedded software developing method and system
JPH11134204A (en) Stack protecting device
CN112003860B (en) Memory management method, system and medium suitable for remote direct memory access

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20240108

Address after: 250001 national information and Communication International Innovation Park, Jinan hi tech Development Zone, Jinan City, Shandong Province

Applicant after: SHANDONG MASS INSTITUTE OF INFORMATION TECHNOLOGY

Address before: 250000 No. 1036, Langchao Road, high tech Zone, Jinan, Shandong Province

Applicant before: INSPUR ELECTRONIC INFORMATION INDUSTRY Co.,Ltd.

TA01 Transfer of patent application right