Method and electronic device for recording target program running status information
Patent Information
- Application Number
- CN202010400975.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-05-13
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2040-05-13
AI Technical Summary
如果正在运行的进程为前台应用程序进程,会出现前台应用程序的闪退;如果正在运行的进程为关键系统进程,可能会导致电子设备重启,上述都会影响用户体验
[0029] In a third aspect, embodiments of the present application provide a computer-readable storage medium. The computer-readable storage medium stores instructions. When executed on a computer, the instructions can cause the computer to perform the method described in any embodiment of the first aspect. . The beneficial effects that can be achieved in the third aspect can be referred to the beneficial effects of the method provided in any embodiment of the first aspect, and will not be described again here.
Smart Images

Figure CN113672445B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method for recording target program running status information, an electronic device, and a computer-readable storage medium. Background Art
[0002] In the Linux signal mechanism, signal 9 is a signal that cannot be captured. When a running process receives signal 9, the process will be forcibly terminated. If the running process is a foreground application process, the foreground application will crash; if the running process is a critical system process, it may cause the electronic device to restart, which will affect the user experience.
[0003] However, when a process is terminated by signal 9, its running status information cannot be recorded. Therefore, program maintainers cannot locate the cause of process termination, which is not conducive to improving the program. Summary of the invention
[0004] Some embodiments of the present application provide a method and an electronic device for recording target program running status information. The present application is introduced from multiple aspects below, and the implementation methods and beneficial effects of the following aspects can be referenced to each other.
[0005] In a first aspect, an embodiment of the present application provides a method for recording target program running status information, comprising: a source process transmits a first signal to a kernel through a system call, the first signal being a signal used to be sent to a target process so that the target process performs a first action, the target process being a process used to execute the target program; the kernel determines whether the delivered first signal is a signal that cannot be captured, and based on the determination result that the first signal is a signal that cannot be captured, sends a second signal to the target process to replace the first signal, wherein the second signal is a signal that can be captured; the target process receives the second signal, and performs processing in response to the second signal, which is processed as a processing action corresponding to the first action.
[0006] When the first signal is a signal that cannot be captured, the target process is forced to execute the default action corresponding to the first signal (for example, terminating the target process, pausing the target process) when receiving the first signal. In this way, the target process will present a fault state to the outside. In an embodiment of the present application, when the first signal sent by the source process to the target process is a signal that cannot be captured, the kernel changes the first signal to a second signal that can be captured and sends the second signal to the target process. Thus, after the target process receives the second signal, it can execute an action corresponding to the first action, for example, execute the first action and record the running status information of the target process, so that the program maintenance personnel can locate the cause of the fault, which is conducive to improving the program.
[0007] In some implementations, the kernel sends the first signal to the target process based on a determination that the first signal is a signal that can be captured; and the target process executes a first action in response to receiving the first signal.
[0008] According to an implementation manner of the present application, when the kernel determines that the first signal is a signal that can be captured, the first signal is sent normally to the target process, so that the target process performs a first action in response to the first signal.
[0009] In some embodiments, the first signal is a signal 9 signal, the first action is to terminate the target process, and the processing corresponding to the first action is to terminate the target process and record the running status information of the target process. For example, a log file including the running status information of the target program is generated, or the running status information of the target process is sent to the server.
[0010] According to an implementation of the present application, when a target process is terminated by signal 9, the running status information of the target process at the time of termination can be recorded to facilitate locating the cause of termination of the target process, which is conducive to improving the program.
[0011] In some implementations, the running status information of the target process includes identification information of the target process and stack information when the target process is terminated.
[0012] According to the implementation manner of the present application, it is helpful to locate the termination reason of the target process.
[0013] In some implementations, the running status information of the target process includes identification information of the source process and / or a signal value of the second signal.
[0014] According to the implementation manner of the present application, it is helpful to locate the direct reason why the target process is terminated.
[0015] In some implementations, the processing action corresponding to the first action is a default processing method corresponding to the second signal.
[0016] According to the implementation manner of the present application, the running status information of the target process can be obtained by executing the default action corresponding to the second signal, which can simplify the design of the program. In some implementation manners, the second signal is signal 3, signal 4, signal 6, signal 8 or signal 11.
[0017] In some implementations, the processing corresponding to the first action is a custom processing method, and the custom processing method includes recording the running status information of the target process by calling a fault recording process.
[0018] According to the implementation manner of the present application, the running status information of the target process can be recorded by calling the fault recording process, which can simplify the design of the program.
[0019] In some implementations, the fault logging process is a debuggerd process.
[0020] According to the implementation of the present application, it can be integrated with the tombstone mechanism, which is not only conducive to simplifying program design, but also can realize the regular aggregation and reporting of operation status information. In some implementations, the second signal is signal 4, signal 5, signal 6, signal 7, signal 8, signal 11 or signal 31.
[0021] In some embodiments, the method also includes: the kernel determines whether the target process is a critical process; and, based on the determination result that the first signal is a signal that cannot be captured and the determination result that the target process is a critical process, the kernel sends a second signal to the target process to replace the first signal.
[0022] According to an implementation of the present application, for a non-critical process, the non-critical process can be normally terminated through the signal 9 signal.
[0023] In some implementations, the target process includes a criticality flag for marking whether the target process is a critical process, and the kernel determines whether the target process is a critical process based on the value of the criticality flag.
[0024] In some implementations, when the target process is a foreground application process, the value of the criticality flag is set to indicate that the target process is a critical process.
[0025] The running status of the foreground application process has a great impact on the user experience. In the implementation mode of the present application, setting it as a key process is conducive to obtaining the running status information of the foreground application and using it as a means to improve the program.
[0026] In some embodiments, the value of the criticality flag of the target process is set by the management process. In some embodiments, the management process sets the value of the criticality flag of the target process in the user space, thereby simplifying the communication process between the management process and the target process.
[0027] In some implementations, the source process is one of the following: the target process itself; other user processes other than the target process. That is, the technical solution of the implementation of the present application is applicable to both the case where a process sends a first signal to another process and the case where a process sends a first signal to itself.
[0028] In a second aspect, an embodiment of the present application provides an electronic device, comprising: a memory for storing instructions executed by one or more processors of the electronic device; a processor, when the processor executes the instructions in the memory, the electronic device can execute the method described in any embodiment of the first aspect of the present application. The beneficial effects that can be achieved in the second aspect can refer to the beneficial effects of the method provided in any embodiment of the first aspect, and will not be repeated here.
[0029] In a third aspect, the present application provides a computer-readable storage medium on which instructions are stored, and when the instructions are executed on a computer, the computer can execute the method described in any embodiment of the first aspect. The beneficial effects that can be achieved in the third aspect can refer to the beneficial effects of the method provided in any embodiment of the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 This is a flowchart of the method for processing signal 11 in the Android native mechanism;
[0031] Figure 2 A schematic diagram of an application scenario of the method for recording target program running status information provided in an embodiment of the present application;
[0032] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0033] Figure 4 A software architecture diagram of an electronic device provided for an embodiment of the present application;
[0034] Figure 5 A flowchart of a method for recording target program running status information provided by an embodiment of the present application;
[0035] Figure 6 A flowchart of a method for recording target program running status information provided by another embodiment of the present application;
[0036] Figure 7 A block diagram of an electronic device provided in an embodiment of the present application is shown;
[0037] Figure 8 A schematic diagram of the structure of a system on chip (SoC) provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0038] The specific implementation of the present application will be described in detail below with reference to the accompanying drawings.
[0039] In order to better illustrate the present application, numerous specific details are provided in the following specific embodiments. It should be understood by those skilled in the art that the present application can also be implemented without certain specific details. In some specific embodiments, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present application.
[0040] Figure 1 The following figure shows the situation when an application process receives signals such as signal 11 and signal 6 in the Android native mechanism. Taking signal 11 as an example, during the operation of the application process, the kernel will send signal 11 to the application process because it accesses an invalid memory address. After receiving signal 11, the application process executes the processing action corresponding to signal 11. In this example, the processing action corresponding to signal 11 is to call the debuggerd process and terminate the application process. By calling the debuggerd process, the running status information of the application process at the time of termination (for example, the process number (Process ID, PID) of the application process, the process name, stack information, etc.) can be captured, and the captured running status information is recorded in the tombstone log. Therefore, this processing mechanism is also called the "tombstone mechanism". The tombstone mechanism will regularly report the information in the tombstone log to the server so that the program maintenance personnel can locate and analyze the failure of the application to improve the application and improve the user experience.
[0041] In the above example, the processing action corresponding to the signal is a user-defined processing action. That is, the user can define the processing action corresponding to each signal in the application, so that the application process can execute the processing action corresponding to the signal after receiving the signal. Specifically, the user can define the correspondence between the signal and the processing action through functions such as signal() and sigaction(). Taking the signal(signum, *sinnal_handler) function as an example, it has two parameters, the first parameter is the signal value of the signal, and the second parameter is a pointer to the function signal_handler(). Among them, the function signal_handler() is a signal processing function, which defines the processing action corresponding to the signal signum, so that when the process receives the signum signal, it will execute the action defined in the signal processing function signal_handler().
[0042] In this article, the signal value of a signal can be the name of the signal or the number of the signal. For example, for the signal 11 signal, its number is "11" and its name is "SIGSEGV", so the signal value of the signal can be "11" or "SIGSEGV". The signal mechanism can be understood as a simulation of the interrupt mechanism at the software level. In other words, a process receiving a signal is similar in principle to a processor receiving an interrupt request (therefore, the signal is also called a "soft interrupt signal"). After receiving the signal, the current process (that is, the process that obtains CPU control) executes the processing action corresponding to the signal.
[0043] The above uses the application process as an example to introduce the processing of the process after receiving the signal. It can be understood that in other examples, the process receiving the signal can also be a system program process. Hereinafter, the process receiving the signal is referred to as the "target process". In addition, this article also refers to the process sending the signal as the "source process", which can be either a system program process or an application process.
[0044] In this article, system programs and application programs are both user programs, running in user space and used to perform user tasks; in contrast to user programs are kernel programs (i.e., operating system programs), which run in kernel space and are used to perform operating system tasks (e.g., allocating CPU time, memory, and other system resources). In order to ensure the safe operation of programs, it is usually required that user program processes cannot directly execute certain instructions that may cause damage (e.g., process scheduling, accessing I / O, terminating another process, etc.), but must request kernel execution through system calls.
[0045] In some cases, if the signal processing function is not defined in the user program, the target process will execute the default processing action corresponding to the signal when it receives the signal. Each signal has a default processing action corresponding to it. For example, the default processing action corresponding to signal 4 is to terminate the target process and generate a core file. Among them, the core file includes the running status information of the target process when it is terminated, which can be used to locate and analyze the cause of the termination of the target process.
[0046] There is a type of signal (including signal 9 (signal name: sigkill) and signal 19 (signal name: sigstop)) for which users cannot customize the corresponding processing actions. When a process receives such a signal, it can only execute the default processing action corresponding to the signal. This article refers to such signals as signals that cannot be captured, and other signals for which the processing actions can be customized are called signals that can be captured.
[0047] When the target process receives a signal that cannot be captured, it is forced to execute the default action corresponding to the signal (for example, terminate the process, suspend the process), and the target process will appear to be in a fault state. However, the cause of the fault cannot be recorded, so the cause of the fault cannot be located. In the following, the signal 9 is used as an example of a signal that cannot be captured to illustrate the technical solution of the present application.
[0048] For signal 9, the corresponding default processing action is to terminate the process. Therefore, when the target process receives signal 9, the process will be terminated directly. If the target process is a foreground application process, the foreground application will crash; if the target process is a system process, it may cause the electronic device to restart, which will have a bad impact on the user experience. However, since the target process cannot be recorded when it is terminated by signal 9, the program maintainer cannot locate the reason for the process termination, which is not conducive to improving the program.
[0049] To this end, an embodiment of the present application provides a method for recording the running status information of a target program, which is used to record the running status information of the target program when a signal is received. Figure 2 An application scenario of an implementation of the present application is shown, in which a source process sends a signal (the signal is an original signal) to a target process.
[0050] Since the sending of signals needs to be implemented through system calls, after the source process sends the original signal, the original signal is first passed to the kernel. After receiving the original signal, the kernel detects the original signal. When the kernel detects that the original signal is a signal 9 signal, it changes it to another signal (called: the changed signal), and sends the changed signal to the target process, wherein the changed signal is a signal that can be captured. In this way, when the target process receives the changed signal, it can execute a processing action in response to the changed signal, and the processing action includes terminating the target process and recording the running status information of the target process when it is terminated. Among them, the running status information of the target process includes the identification information of the target process (for example, the PID of the target process, the process name of the target process), the stack information of the target process when it is terminated, etc.
[0051] That is, in the implementation mode of the present application, the kernel will identify the initial signal sent by the source process. If the initial signal sent by the source process is a signal 9 that cannot be captured, it will be changed to a signal that can be captured. When the target process receives the changed signal, it terminates the process and records the running status information of the process at the time of termination. In this way, the program maintenance personnel can locate the reason why the process was terminated based on the running status information, so as to improve the program.
[0052] It should be noted that the application scenario of the implementation scheme of the present application can also be Figure 2 Other scenes than those shown.
[0053] For example, in another scenario, the target process sends a signal 9 to itself based on some operational anomalies to actively terminate the process. The process operational anomalies may include calculation overflow, insufficient external storage space, file read failure, long-term I / O non-response, etc.
[0054] For example, in another scenario, after receiving the original signal, the kernel detects the original signal. When the kernel detects that the original signal is signal 19 (which is used to suspend the target process and cannot be captured), it changes it to another signal. When the target process receives the changed signal, it suspends the process and records the running status information.
[0055] Figure 3 FIG. 1 is a schematic diagram of the structure of an electronic device 100 according to an embodiment of the present application. The electronic device 100 may be implemented as a mobile phone, a tablet, a wearable device, etc., which is not limited in this embodiment.
[0056] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) connector 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0057] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0058] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0059] The processor can generate operation control signals based on instruction opcodes and timing signals to complete the control of instruction fetching and execution.
[0060] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0061] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, and a subscriber identity module (SIM) interface.
[0062] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example: the processor 110 may be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface, thereby realizing the touch function of the electronic device 100.
[0063] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call through a Bluetooth headset.
[0064] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
[0065] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.
[0066] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the electronic device 100.
[0067] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0068] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0069] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0070] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0071] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0072] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0073] The internal memory 121 can be used to store computer executable program codes, and the executable program codes include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (universal flash storage, UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121, and / or instructions stored in a memory provided in the processor. In this embodiment, instructions are stored in the internal memory 121, and when the instructions are executed by the processor 110, the electronic device 100 can execute the method for recording the target program running status information provided in the embodiment of the present application.
[0074] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the Android system of the layered architecture is taken as an example to exemplify the software structure of the electronic device 100.
[0075] Figure 4 1 is a software structure block diagram of the electronic device 100 according to an embodiment of the present invention.
[0076] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.
[0077] The application layer can include a series of application packages.
[0078] like Figure 4 As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0079] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0080] like Figure 4 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0081] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0082] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0083] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0084] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).
[0085] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0086] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0087] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0088] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0089] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0090] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0091] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0092] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0093] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0094] A 2D graphics engine is a drawing engine for 2D drawings.
[0095] The kernel layer is a layer between hardware and software. The kernel layer includes at least a display driver, a camera driver, an audio driver, and a sensor driver. The kernel also includes a signal management module, which is a software module for implementing the method for recording the running status information of the target program provided in the embodiment of the present application. In this embodiment, when the source process sends a signal to the target process through a system call, the signal will first reach the signal management module. The signal management module identifies the received signal. If the signal sent by the source process is a signal 9 signal, the signal management module changes it to a signal that can be captured, and then sends the changed signal to the target process.
[0096] The following combination Figure 2 The illustrated scenarios illustrate specific embodiments of the present application.
[0097] [Example 1]
[0098] This embodiment provides a method for recording the running status information of a target program. In this embodiment, when a source process sends a signal to a target process through a system call, after the original signal sent by the source process reaches the kernel, the kernel identifies the original signal. If the original signal is a signal 9 signal, it is changed to a signal that can be captured, and then the changed signal is sent to the target process. After receiving the changed signal, the target process executes a processing action corresponding to the changed signal, and the processing action includes terminating the target process and recording the running status information of the target process at the time of termination. Thus, the program maintenance personnel can locate the termination cause of the target process based on the running status information of the target process, which is conducive to improving the program.
[0099] Specifically, refer to Figure 5 , the method provided in this embodiment includes the following steps:
[0100] S110: The source process transmits an original signal to the kernel through a system call, where the original signal is a signal used to be sent to the target process.
[0101] In this embodiment, the source process sends a signal (the signal is the original signal) by calling the system function kill(). After the source process initiates the system call, the original signal is first transmitted to the kernel. In this embodiment, the original signal is transmitted to the signal management module of the kernel.
[0102] The first parameter of the kill(pid, signum) function is the PID of the target process, and the second parameter is the signal value of the original signal. That is, the original signal is the signum signal sent to the target process whose process ID is PID. In other embodiments, the source process can also call the system function sigqueue() to send a signal to the target process, or call the system function raise() to send a signal to itself.
[0103] This embodiment does not limit the signal value of the original signal. The original signal may be a signal that cannot be captured, such as signal 9; or may be a signal that can be captured, such as signal 4, signal 6, etc.
[0104] This embodiment does not limit the reasons why the source process sends the original signal to the target process. For example, when the target process is a process that has not passed the security authentication, the virus monitoring process sends the signal 9 signal to it; when the target process obtains more permissions than it needs, the system management process sends the signal 15 signal to it; when the target process occupies too many system resources (such as memory resources), the system process sends the signal 6 signal to it; when the power consumption of a process exceeds the set threshold, the power management process sends the signal 19 signal to it.
[0105] S120: The kernel determines whether the delivered original signal is signal 9. If so, step S130 is executed to convert the original signal; if not, step S140 is executed to continue sending the original signal to the target process.
[0106] Specifically, the signal management module identifies the delivered original signal. If the original signal is a signal 9 signal, step S130 is executed to convert the original signal; if the original signal is not a signal 9 signal, step S140 is executed to continue sending the original signal to the target process.
[0107] The following specifically describes the case where it is determined in step S120 that the original signal is the signal 9 signal.
[0108] S130: The kernel changes the original signal and sends the changed signal to the target process.
[0109] The kernel sends a signal to the target process by setting a bit corresponding to the signal in the signal field of the process table entry where the target process is located. That is, the kernel sends a modified signal to the target process by setting a bit corresponding to the modified signal in the signal field of the process table entry where the target process is located, rather than setting a bit corresponding to the original signal.
[0110] The changed signal is a signal that can be captured. Specifically, the changed signal can be one of signal 4 (signal name: SIGILL), signal 5 (signal name: SIGTRAP), signal 6 (signal name: SIGBRT), signal 7 (signal name: SIGBUS), signal 8 (signal name: SIGFPEE), signal 11 (signal name: SIGSEGV), or signal 31 (signal name: SIGSYS). The above signals are signals registered in the tombstone mechanism. In other words, in the tombstone mechanism, when the target program receives the above signals, the signal processing function will call the debuggerd process to generate a tombstone log.
[0111] The present application is not limited thereto. For example, in some other embodiments, the changed signal is one of signal 3 (signal name: SIGQUIT), signal 4 (signal name: SIGILL), signal 6 (signal name: SIGBRT), signal 8 (signal name: SIGFPE), and signal 11 (signal name: SIGSEGV). The default processing actions corresponding to these signals are to terminate the process and generate a status log file (for example, a core file), so that the target process can obtain the status log file by executing the default action corresponding to the signal; in some other embodiments, the changed signal is other signals that can be captured that are not mentioned above.
[0112] S140: In response to receiving the changed signal, the target process executes processing corresponding to the changed signal, wherein the processing corresponding to the changed signal is to record the running status information of the target process and terminate the target process.
[0113] In this embodiment, the user customizes the processing action corresponding to the changed signal through the signal processing function signal_handle(). Specifically, the signal processing function signal_handle() includes calling a fault recording process to record the running status information of the target process through the fault recording process.
[0114] Specifically, the fault recording process is the debuggerd process. As described above, by calling the debuggerd process, the running status information of the application process before termination can be captured, and the captured running status information can be recorded in the tombstone log. In other words, this embodiment is integrated with the tombstone mechanism, which not only helps to simplify program design, but also realizes the regular aggregation and reporting of running status information.
[0115] In this embodiment, the running state information of the target process includes: identification information of the target process (e.g., PID of the target process, process name of the target process), and stack information of the target process when it is terminated. Thus, by analyzing the running state information, the termination cause of the target process can be located so as to improve the program.
[0116] It can be understood that the above embodiments are exemplary descriptions of the implementation methods of the present application, and those skilled in the art may make other modifications.
[0117] For example, in some embodiments, the processing action corresponding to the changed signal is the default processing action corresponding to the signal. In this embodiment, when the changed signal is signal 4, signal 5, signal 6 or signal 7, the corresponding default processing action is to generate a core file (including the running status information of the target process) and terminate the target process. In this way, the target process can record the running status information of the target process by executing the default processing action corresponding to the changed signal. This embodiment can simplify the design of the program.
[0118] For example, in some embodiments, the running status information of the target process includes the identification of the source process (for example, the PID of the source process, the name of the source process), and / or the signal value of the signal received by the target process, so as to locate the direct cause of the termination of the target process.
[0119] The following specifically describes the situation in which it is determined that the original signal is not the signal 9 signal in step S120.
[0120] S150: The kernel sends the original signal to the target process. As mentioned above, the kernel sends the original signal to the target process by setting a bit corresponding to the original signal in the signal field of the process table entry where the target process is located, which will not be described in detail.
[0121] S160: In response to receiving the original signal, the target process executes the processing corresponding to the original signal, for example, terminating the process, pausing the process, etc. In addition, the processing corresponding to the original signal can be a user-defined processing or a default processing corresponding to the original signal, which is not limited in this embodiment.
[0122] In this embodiment, the kernel identifies the original signal sent by the source process, and when the original signal is signal 9, changes it to a captureable signal, and sends the changed signal to the target process. In this way, after receiving the changed signal, the target process can record the running status information of the target program, so as to locate the termination cause of the target process later, and use this as a means to improve the program.
[0123] [Example 2]
[0124] This embodiment provides another method for recording the running status information of the target process. Different from the first embodiment, in this embodiment, a step of judging the criticality of the target process is added. When the target process is a critical process, the originally sent signal 9 is replaced with the changed signal; for non-critical processes, the original signal is sent normally (the original signal may be the signal 9 signal). In this embodiment, the non-critical process can be terminated normally by the signal 9 signal. Specifically, refer to Figure 6 , this embodiment includes the following steps:
[0125] S210: Setting the value of the criticality flag of the target process.
[0126] In this embodiment, the identifier of the criticality flag is flag_exit_catch. When the value of flag_exit_catch is 1, it indicates that the target process is a critical process; when the value of flag_exit_catch is 0, it indicates that the target process is a non-critical process. It can be understood that the present application is not limited to this. For example, in other embodiments, when the value of flag_exit_catch is "true", it indicates that the target process is a critical process.
[0127] The value of flag_exit_catch is set by the management process. The management process determines the value of flag_exit_catch of the target process according to the importance of the target process. For example, when the target process is an application process running in the foreground, its running state has a greater impact on the user experience. Therefore, the management process sets the value of flag_exit_catch of the target process to 1; for another example, when the target process is a critical system process (for example, the dial-up service process of a mobile phone), the management process sets the value of flag_exit_catch to 1.
[0128] In this embodiment, the management process is a user process, and the management process sets the value of flag_exit_catch of the target process in the user space, thereby simplifying the communication process between the management process and the target process.
[0129] After obtaining the value of flag_exit_catch, the target process passes the value of flag_exit_catch to the kernel space so that in the subsequent steps the kernel can determine whether the target process is a critical process based on the value of flag_exit_catch.
[0130] It can be understood that the setting method of flag_exit_catch provided in this embodiment is only for illustrative purposes, and those skilled in the art may make other variations. For example, in another embodiment, the value of flag_exit_catch is managed by the target program itself, that is, the default value of flag_exit_catch is set in the target program, and flag_exit_catch is assigned the default value when the target process is initialized; in another embodiment, after determining the flag_exit_catch of the target process, the management process directly passes the value to the kernel address space.
[0131] S220: The source process transmits the original signal to the kernel through the system call, and the original signal is the signal used to be sent to the target process. For example, the source process sends a signal by calling the system function kill() (the signal is the original signal). After the source process initiates the system call, the original signal is first transmitted to the kernel.
[0132] This step is substantially the same as step S110 in the first embodiment, and the specific details thereof may refer to step S110 in the first embodiment.
[0133] S230: The kernel determines whether the delivered original signal is signal 9. If so, step S240 is executed to determine whether the target process is a critical process; if not, step S270 is executed to continue sending the original signal to the target process.
[0134] That is, the kernel identifies the delivered original signal. If the original signal is signal 9, step S240 is executed to further determine whether the target process is a critical process; if the original signal is not signal 9, step S280 is executed to continue sending the original signal to the target process.
[0135] The following specifically describes the case where it is determined in step S230 that the original signal is the signal 9 signal.
[0136] S240: The kernel determines whether the target process is a critical process. Specifically, the kernel obtains the value of flag_exit_catch of the target process from the kernel address space. If the value of flag_exit_catch is 1, the target process is determined to be a critical process, and step S260 is executed to convert the original signal; if the value of flag_exit_catch is 0, the target process is determined to be a non-critical process, and step S270 is executed to continue sending the original signal to the target process.
[0137] S250: The kernel changes the original signal and sends the changed signal to the target process, that is, the kernel sets a bit corresponding to the changed signal in the signal field of the process representation of the target process to replace the bit corresponding to the original signal.
[0138] S260: In response to receiving the changed signal, the target process executes processing corresponding to the changed signal, wherein the processing corresponding to the changed signal is to record the running status information of the target process and terminate the target process.
[0139] In this embodiment, the running state information of the target process includes: identification information of the target process (e.g., PID of the target process, process name of the target process), and stack information of the target process when it is terminated. Thus, by analyzing the running state information, the termination cause of the target process can be located so as to improve the program.
[0140] In other embodiments, the running status information of the target process includes the identifier of the source process (e.g., the PID of the source process, the name of the source process), and / or the signal value of the signal received by the target process, so as to locate the direct cause of the termination of the target process.
[0141] The following specifically describes the situation in which it is determined that the original signal is not the signal 9 signal in step S230.
[0142] S270: The kernel sends the original signal to the target process. As mentioned above, the kernel sends the original signal to the target process by setting a bit corresponding to the original signal in the signal field of the process table entry where the target process is located, which will not be described in detail.
[0143] S280: In response to receiving the original signal, the target process executes the processing corresponding to the original signal, for example, terminating the process, pausing the process, etc. In addition, the processing corresponding to the original signal can be a user-defined processing or a default processing corresponding to the original signal, which is not limited in this embodiment.
[0144] In this embodiment, steps S250 to S280 are substantially the same as steps S130 to S160 in the first embodiment, and the detailed processes in the steps are not repeated any more.
[0145] In this embodiment, when the original signal sent by the source process to the target process is signal 9 and the target process is a critical process, the original signal is changed. When the target process is a non-critical process, the kernel normally sends the original signal to the target process. In this embodiment, the non-critical process can be terminated normally by the signal 9 signal.
[0146] It can be understood that the first and second embodiments are exemplary descriptions of the technical solution of the present application, and those skilled in the art may adopt other variations. For example, the order of step S230 and step S240 in the second embodiment may be interchanged; for another example, when the kernel management module determines that the original signal is signal 19, it changes it and sends the changed signal to the target process. When the target process receives the changed signal, it suspends the process and records the running status information.
[0147] Reference now Figure 7 , shown is a block diagram of an electronic device 400 according to one embodiment of the present application. The electronic device 400 may include one or more processors 401 coupled to a controller hub 403. For at least one embodiment, the controller hub 403 communicates with the processor 401 via a multi-drop bus such as a front side bus (FSB), a point-to-point interface such as a QuickPath Interconnect (QPI), or a similar connection 406. The processor 401 executes instructions that control general types of data processing operations. In one embodiment, the controller hub 403 includes, but is not limited to, a graphics memory controller hub (GMCH, Graphics & Memory Controller Hub) (not shown) and an input / output hub (IOH, Input Output Hub) (which may be on a separate chip) (not shown), wherein the GMCH includes a memory and a graphics controller and is coupled to the IOH.
[0148] The electronic device 400 may also include a coprocessor 402 and a memory 404 coupled to a controller hub 403. Alternatively, one or both of the memory and the GMCH may be integrated within the processor (as described in this application), with the memory 404 and the coprocessor 402 being directly coupled to the processor 401 and the controller hub 403, with the controller hub 403 being in a single chip with the IOH.
[0149] The memory 404 may be, for example, a dynamic random access memory (DRAM), a phase change memory (PCM), or a combination of the two. The memory 404 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. The computer-readable storage medium stores instructions, specifically, temporary and permanent copies of the instructions. The instructions may include: when executed by at least one of the processors, causing the electronic device 400 to implement the following: Figure 5 , Figure 6When the instructions are executed on a computer, the computer executes the method disclosed in the first embodiment and / or the second embodiment.
[0150] In one embodiment, the coprocessor 402 is a special purpose processor, such as, for example, a high throughput MIC (Many Integrated Core) processor, a network or communication processor, a compression engine, a graphics processor, a GPGPU (General-purpose computing on graphics processing units), or an embedded processor. The optional nature of the coprocessor 402 is indicated by a dashed line in FIG. Figure 7 middle.
[0151] In one embodiment, the electronic device 400 may further include a network interface (NIC, Network Interface Controller) 406. The network interface 406 may include a transceiver for providing a radio interface for the electronic device 400, and then communicating with any other suitable device (such as a front-end module, an antenna, etc.). In various embodiments, the network interface 406 may be integrated with other components of the electronic device 400. The network interface 406 may implement the functions of the communication unit in the above-mentioned embodiments.
[0152] The electronic device 400 may further include an input / output (I / O) device 405. The I / O 405 may include: a user interface designed to enable a user to interact with the electronic device 400; a peripheral component interface designed to enable peripheral components to interact with the electronic device 400; and / or a sensor designed to determine environmental conditions and / or location information related to the electronic device 400.
[0153] It is worth noting that Figure 7 This is for illustrative purposes only. Figure 7 It is shown that the electronic device 400 includes multiple devices such as a processor 401, a controller hub 403, a memory 404, etc.; however, in actual applications, the device using the methods of the present application may include only a portion of the devices in the electronic device 400, for example, it may include only the processor 401 and the network interface 406. Figure 7 The properties of optional devices are shown with dotted lines.
[0154] Reference now Figure 8 , which is a block diagram of a SoC (System on Chip) 500 according to an embodiment of the present application. Figure 8 In the FIG, similar components have the same reference numerals. In addition, the dashed boxes are optional features of more advanced SoCs. Figure 8 In the embodiment, SoC 500 includes: an interconnect unit 550 coupled to a processor 510; a system agent unit 580; a bus controller unit 590; an integrated memory controller unit 540; a group or one or more coprocessors 520, which may include integrated graphics logic, an image processor, an audio processor, and a video processor; a static random access memory (SRAM) unit 530; and a direct memory access (DMA) unit 560. In one embodiment, the coprocessor 520 includes a special-purpose processor, such as, for example, a network or communication processor, a compression engine, a GPGPU (General-purpose computing on graphics processing units), a high-throughput MIC processor, or an embedded processor.
[0155] Static random access memory (SRAM) unit 530 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. The computer-readable storage medium stores instructions, and more specifically, stores temporary and permanent copies of the instructions. The instructions may include: when executed by at least one of the processors, causing the SoC to implement the following: Figure 5 , Figure 6 When the instructions are executed on a computer, the computer executes the method disclosed in the first embodiment and / or the second embodiment.
[0156] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0157] Each method implementation mode of the present application can be implemented in the form of software, magnetic components, firmware, etc.
[0158] Program code can be applied to input instructions to perform each function described herein and generate output information. The output information can be applied to one or more output devices in a known manner. For the purpose of this application, the processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.
[0159] Program code can be implemented with high-level programming language or object-oriented programming language to communicate with the processing system. When necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described herein is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.
[0160] One or more aspects of at least one embodiment may be implemented by representative instructions stored on a computer-readable storage medium, which represent various logics in a processor, and when the instructions are read by a machine, the machine makes logic for performing the techniques described herein. These representations, known as "IP (Intellectual Property, Intellectual Property) cores", may be stored on a tangible computer-readable storage medium and provided to multiple customers or production facilities to be loaded into a manufacturing machine that actually manufactures the logic or processor.
[0161] In some cases, the instruction converter can be used to convert instructions from a source instruction set to a target instruction set. For example, the instruction converter can transform (e.g., using static binary transformation, dynamic binary transformation including dynamic compilation), deform, simulate, or otherwise convert instructions into one or more other instructions to be processed by the core. The instruction converter can be implemented in software, hardware, firmware, or a combination thereof. The instruction converter can be on the processor, outside the processor, or partially on the processor and partially outside the processor.
Claims
1. A method for recording target program running status information, characterized in that: include: The source process transmits a first signal to the kernel through a system call, wherein the first signal is a signal used to be sent to a target process so that the target process performs a first action, and the target process is a process used to execute the target program; The kernel determines whether the first signal delivered is a signal that cannot be captured, and based on the determination result that the first signal is a signal that cannot be captured, sends a second signal for replacing the first signal to the target process, wherein the second signal is a signal that can be captured; The target process receives the second signal and performs processing in response to the second signal, wherein the processing is a processing action corresponding to the first action, and the processing at least includes recording processing of the running status information of the target process.
2. The method according to claim 1, characterized in that The kernel sends the first signal to the target process based on a determination result that the first signal is a signal that can be captured; Furthermore, the target process executes the first action in response to receiving the first signal.
3. The method according to claim 1, characterized in that: The first signal is a signal 9 signal, the first action is to terminate the target process, and the processing action corresponding to the first action is to terminate the target process and record the running status information of the target process.
4. The method according to claim 3, characterized in that The running status information of the target process includes identification information of the target process and stack information when the target process is terminated.
5. The method according to claim 3 or 4, characterized in that: The running status information of the target process includes identification information of the source process and / or a signal value of the second signal.
6. The method according to claim 3, characterized in that: The processing action corresponding to the first action is a default processing method corresponding to the second signal.
7. The method according to claim 6, characterized in that The second signal is a signal 3 signal, a signal 4 signal, a signal 6 signal, a signal 8 signal or a signal 11 signal.
8. The method according to claim 3, characterized in that The processing action corresponding to the first action is a custom processing method, and the custom processing method includes recording the running status information of the target process by calling a fault recording process.
9. The method according to claim 8, characterized in that The fault recording process is the debuggerd process.
10. The method according to claim 9, characterized in that The second signal is a signal 4 signal, a signal 5 signal, a signal 6 signal, a signal 7 signal, a signal 8 signal, a signal 11 signal or a signal 31 signal.
11. The method according to claim 1 or 3, characterized in that: The method further comprises: The kernel determines whether the target process is a critical process; Furthermore, based on the determination result that the first signal is a signal that cannot be captured and the determination result that the target process is a critical process, the kernel sends the second signal for replacing the first signal to the target process.
12. The method according to claim 11, characterized in that The target process includes a criticality flag bit for marking whether the target process is a critical process, and the kernel determines whether the target process is a critical process according to the value of the criticality flag bit.
13. The method according to claim 12, characterized in that When the target process is a foreground application process, the value of the criticality flag is set to indicate that the target process is a critical process.
14. The method according to claim 12, characterized in that The value of the criticality flag of the target process is set by the management process.
15. The method according to claim 14, characterized in that The management process sets the value of the criticality flag of the target process in the user space.
16. The method according to claim 1, characterized in that The source process is one of the following: the target process itself; or other user processes other than the target process.
17. An electronic device, characterized in that: include: a memory for storing instructions executed by one or more processors of the electronic device; A processor, when the processor executes the instructions in the memory, can cause the electronic device to execute the method according to any one of claims 1 to 16.
18. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method according to any one of claims 1 to 16.
