Abnormal process determination method, electronic equipment and computer readable storage medium

By detecting processes with abnormal communication states and generating a communication link table, and outputting information about their downstream processes, the problem of being unable to locate abnormal processes in existing technologies is solved, achieving the effect of accurately locating and correctly maintaining abnormal processes.

CN121433944APending Publication Date: 2026-01-30HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411029832.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-29
Publication Date
2026-01-30

AI Technical Summary

Technical Problem

Existing technologies cannot effectively locate abnormal processes that cause operating system tasks to malfunction, resulting in the inability to perform proper maintenance and causing the tasks to malfunction again the next time they are executed.

Method used

By detecting processes with abnormal communication states, their communication relationship information is obtained, and a communication link table is generated. The table outputs information about all processes downstream of the communication link in which the abnormal process is located, including information about abnormal processes, so that developers can maintain it.

Benefits of technology

It can accurately locate abnormal processes, ensuring that developers can perform proper maintenance and prevent the task from failing again.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121433944A_ABST
    Figure CN121433944A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and provides an abnormal process determination method, electronic equipment and a computer readable storage medium. According to the method, when the electronic equipment detects that the duration of waiting for receiving a message by a first process reaches a first preset duration, the electronic equipment determines that the first process has communication abnormality, and at the moment, the electronic equipment can obtain communication relationship information among the processes; and then outputting process information of each downstream process of the communication link where the first process is located according to the communication relation information. Because the abnormal process with the response abnormity of the first process is inevitably located at the downstream of the communication link where the first process is located, the process information output by the electronic equipment inevitably comprises the process information of the abnormal process. Therefore, a developer can inevitably determine the abnormal process which causes the response abnormity of the first process according to the process information output by the electronic equipment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method for determining abnormal processes, an electronic device, and a readable storage medium. Background Technology

[0002] Operating system (e.g.) system, In systems (such as ERP systems), different processes can communicate with each other, for example... Processes in the system can communicate with each other using the Binder mechanism (IPC) to transfer data and ensure that the tasks they jointly execute can be performed successfully.

[0003] When an operating system encounters an error while executing a task (such as starting an application), determining the cause of the error requires locating the malfunctioning process within the task's execution process. Then, appropriate maintenance is performed based on this malfunctioning process to ensure the task executes correctly the next time. However, in some cases, existing technology cannot locate the malfunctioning process, preventing developers from performing proper maintenance and causing the task to malfunction again the next time it is executed. Summary of the Invention

[0004] Some embodiments of this application provide a method for determining abnormal processes, an electronic device, and a computer-readable storage medium. The following describes this application from multiple aspects, and the embodiments and beneficial effects of these aspects can be referred to each other.

[0005] In a first aspect, this application provides a method for determining an abnormal process for an electronic device. The method includes: detecting that a first process is in an abnormal communication state; obtaining first communication relationship information of the first process, the first communication relationship information including the communication relationship between processes downstream of the communication link in which the first process is located; and obtaining process information of each process downstream of the communication link in which the first process is located based on the first communication relationship information, wherein the process information includes process information of a second process that causes the first process to be in an abnormal communication state.

[0006] When an electronic device detects that the first process is in an abnormal communication state, it can output the process information of each process downstream of the first process in the communication link, based on the first process's initial communication relationship information. Since the abnormal process causing the first process's abnormal communication state must be downstream of the first process's communication link, the process information output by the electronic device will inevitably contain information about this abnormal process. Therefore, developers can locate the abnormal process causing the first process's communication anomaly based on the process information output by the electronic device.

[0007] In some implementations, detecting that the first process is in an abnormal communication state includes: detecting that the first process triggers an application unresponsive mechanism; or detecting that the first process triggers a watchdog mechanism.

[0008] In some implementations, obtaining the first communication relationship information of the first process includes: obtaining the first communication relationship information of the first process from a communication link table by means of the identifier of the first process, wherein the communication link table includes the communication relationship information of processes in each communication.

[0009] The identifier of the first process includes, but is not limited to, process identifier, process name, etc.

[0010] In some implementations, the communication link table is obtained by: generating a blank table in a format corresponding to the communication link table; detecting that a first process sends a communication request to a second process; and adding the first communication relationship information of the first process to the blank table to obtain the communication link table.

[0011] After the electronic device starts up, it can generate a blank table in the format corresponding to the communication link table. Then, when the electronic device detects that the first process sends a communication request, such as an IPC request, to the second process, it can store the second communication relationship information of the first process into the communication link table. In this way, the communication relationship information of each process in communication can be added to the blank table to obtain the communication link table.

[0012] In some implementations, the communication link table also includes second communication relationship information of the third process, which is added to the communication link table when the third process sends a communication request to the fourth process. The second communication relationship information includes the communication relationship between the third process and the fourth process. The second communication relationship information in the communication link table is deleted in the following case: the communication between the third process and the fourth process ends.

[0013] For example, when an electronic device detects that a third process sends a communication request to a fourth process, it adds the third process's second communication relationship information to the communication link table. Then, when the electronic device detects that the third process and the fourth process have ended communication, it can delete the third process's second communication relationship information from the communication link table to save storage space.

[0014] In some implementations, based on the first communication relationship information, process information of the first process and each process downstream of the first process in the communication link is obtained, including: based on the first communication relationship information, determining the communication level of each process downstream of the first process in the communication link; and writing the process information of each process downstream of the first process in the communication link into a first file according to the level.

[0015] The process information of each process is output according to the corresponding communication level on the communication link. This makes it easier for developers to determine the communication relationship between each process based on the level of the process information. This also makes it easier for developers to deduce the abnormal process that caused the abnormal communication state of the first process based on the communication relationship between each process.

[0016] In some implementations, the electronic device may also output process information of the first process, and the process information of the first process is located at the first level.

[0017] In some implementations, the first file includes at least one of the following: log, image, plain text file, portable document format file, rich text format file.

[0018] Secondly, embodiments of this application provide an electronic device, including: a memory for storing instructions executable by one or more processors of the electronic device; and a processor, which, when executing the instructions in the memory, causes the electronic device to perform the method described in any embodiment of the first aspect of this application. The beneficial effects achievable in the second aspect can be referred to the beneficial effects of the method provided in any embodiment of the first aspect, and will not be repeated here.

[0019] Thirdly, embodiments of this application provide a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the method described in any embodiment of the first aspect. The beneficial effects achievable through this third aspect can be referenced to the beneficial effects of the method provided in any embodiment of the first aspect, and will not be repeated here.

[0020] Fourthly, embodiments of this application provide a computer program product, which includes a computer program / instructions. When the computer program / instructions are executed on a computer, the computer causes the computer to implement the method described in any embodiment of the first aspect. The beneficial effects achievable in this fourth aspect can be found in the beneficial effects of the method provided in any embodiment of the first aspect, and will not be repeated here. Attached Figure Description

[0021] Figures 1A-1C Exemplary application scenarios of this application are illustrated;

[0022] Figures 2A-2B An example diagram of the display interface of mobile phone 100 is shown;

[0023] Figures 3A-3B A flowchart illustrating the camera application startup process is shown.

[0024] Figure 4 This diagram illustrates the principle of how mobile phone 100 outputs process information using the LRU algorithm.

[0025] Figure 5 A schematic diagram of the method for determining abnormal processes provided in an embodiment of this application is shown.

[0026] Figure 6 An example diagram of the method for determining abnormal processes provided in an embodiment of this application is shown;

[0027] Figure 7 The diagram illustrates the generation principle of communication link table M1;

[0028] Figures 8A-8C The diagram illustrates the generation principle of communication link table M2;

[0029] Figure 9 An example diagram showing how process information is output is provided.

[0030] Figure 10 A flowchart of the method for determining abnormal processes provided in an embodiment of this application is shown;

[0031] Figure 11 A schematic diagram of the electronic device is shown. Detailed Implementation

[0032] This application provides a method for determining abnormal processes. The method for determining abnormal processes according to this application will be described below with reference to specific embodiments.

[0033] This application does not limit the specific form of the electronic device. For example, the electronic device can be a mobile phone, tablet, smart screen, wearable device (e.g., watch, smart glasses, helmet), desktop computer, augmented reality (AR) / virtual reality (VR) device, personal digital assistant (PDA), in-vehicle mobile device (e.g., car infotainment system), etc. The following uses a mobile phone as an example of an electronic device.

[0034] Figures 1A-1C An exemplary application scenario of this application is shown.

[0035] refer to Figure 1A The phone has a camera app installed for taking photos or recording videos. For example... Figure 1A As shown, when the mobile phone 100 detects that the user clicks the camera application icon 11 on the desktop 10, the mobile phone 100 launches the camera application. After the camera application is launched, it displays the preview interface 20 and captures a preview image. At this time, the user can control the camera application of the mobile phone 100 to take a picture by clicking the shutter button 16 on the preview interface 20 and obtain the desired image.

[0036] However, in some cases, the camera app on the phone becomes unresponsive after startup, meaning it cannot capture or preview images, preventing users from taking photos or recording videos using the camera app.

[0037] For example, such as Figure 1B As shown, when phone 100 detects that the user clicks the camera application icon 11 on the desktop 10, phone 100 launches the camera application. After launching, the camera application displays a preview interface 20. However, after displaying the preview interface 20, the camera becomes unresponsive, meaning it cannot capture preview images, and therefore cannot take photos or record videos. (Reference) Figure 1C When the time it takes for the camera application to respond reaches the first preset time (such as 5s, 6s, 7s, etc.), the phone displays a prompt box 21 to inform the user that "the camera application is not responding".

[0038] In some cases, refer to Figure 2A After the phone displays the prompt box 21, when the phone detects that the user clicks the button on the prompt box 21 - "Force Stop", the phone closes the camera application and returns to the desktop 10.

[0039] In other cases, refer to Figure 2B After displaying the prompt box 21 on phone 100, when phone 100 detects that the user has clicked the "Wait" button on the prompt box 21, phone 100 will continue to wait for the camera application to respond. However, if the phone 100 continues to wait for a second preset time (such as 5s, 6s, 7s, etc.) and the camera application still does not respond, phone 100 will close the camera application and return to the desktop 10.

[0040] Figures 3A-3B This shows a flowchart illustrating the camera application startup process. Below is a comparison. Figure 3A and Figure 3B This section explains why the camera application becomes unresponsive after startup.

[0041] Figure 3A The above is shown Figure 1A The diagram shown is an example of the camera application startup process.

[0042] refer to Figure 3A After the phone 100 is powered on, its camera service process and camera provider process start. The camera service process provides a unified interface for upper-layer applications and is responsible for coordinating and managing camera-related operations. The camera provider process provides a unified interface for the camera service process and performs operations such as opening the camera device and initializing the camera's hardware parameters.

[0043] When the phone detects the camera application's launch command (such as the one mentioned above) Figure 1A When the user clicks the camera application icon 11 on the desktop 10, the phone 100 launches the camera application process—the camera process. After launching, the camera process displays the camera application's preview interface 20 and sends an IPC request to the camera service process to request the initialization of the camera's hardware parameters. The camera service process then forwards this IPC request to the camera service provider process. Upon receiving the IPC request from the camera service process, the camera service provider process initializes the camera's hardware parameters. Then, the camera service provider process returns the camera's initialized hardware parameters (as a message) to the camera service process. The camera service process then returns the camera's initialized hardware parameters to the camera process. Upon receiving the camera's initialized hardware parameters, the camera process captures a preview image based on these parameters. In this case, the camera application launches normally and can take photos or record videos.

[0044] Figure 3B The above is shown Figure 1B The diagram shown is an example of the camera application startup process.

[0045] refer to Figure 3B After phone 100 is powered on, its camera service process starts successfully, but the camera service provider process fails to start. When phone 100 detects a startup command (such as the one mentioned above)... Figure 1B When the user clicks the camera application icon 11 on the desktop 10, the phone 100 starts the camera process. After the camera process starts, it displays the preview interface 20 of the camera application and sends an IPC request to the camera service process to request the initialization of the camera's hardware parameters. Then, the camera service process forwards the IPC request to the camera service provider process.

[0046] Because the camera service provider process failed to start, it could not receive the IPC requests sent by the camera service process, and therefore could not initialize the camera's hardware parameters. Consequently, it could not return the camera's initialization hardware parameters to the camera service process. As a result, the camera process could not obtain the camera's initialization hardware parameters, and therefore could not capture preview images, take photos, or record video.

[0047] When the camera process waits for the camera service process to return the camera's initialization hardware parameters for a period of time, the camera process's response times out, triggering the phone's application not responding (ANR) mechanism (a mechanism used to indicate that an application has not responded to user operations for a period of time) or watchdog mechanism. The phone displays the above information. Figure 1CThe dialog box 21 shown here is used to inform the user that "the camera app is not responding".

[0048] In some embodiments, when the mobile phone 100 detects that the camera process has triggered the ANR mechanism, the mobile phone 100 can use the least recently used (LRU) algorithm to collect process information of the relevant process (such as process state information, stack information (such as local variables, function call parameters, return addresses, and other temporary data), etc.), and output this process information by generating logs or file records. Then, developers can obtain the process information output by the mobile phone 100 when the camera process triggers the ANR mechanism by capturing logs or reading files, and locate the abnormal process that caused the camera process to trigger the ANR mechanism based on this process information, so as to perform corresponding maintenance and prevent the camera application from triggering the ANR mechanism again the next time it starts. However, the process information collected by the LRU algorithm is the process information of the most recently active (e.g., processes that have been running for a period of time (e.g., 5s, 6s, 7s, etc.) processes. If the abnormal process has not been active recently, the mobile phone 100 will not be able to collect the process information of the abnormal process using the LRU algorithm. Furthermore, since the process information collected using the LRU algorithm does not include information on communication relationships between processes, even if an abnormal process has been active recently, it is difficult for the phone 100 to completely determine whether the abnormal process caused the camera process to trigger the ANR mechanism when it collects the process information of the abnormal process using the LRU algorithm.

[0049] Figure 4 The diagram illustrates the principle of how mobile phone 100 outputs process information using the LRU algorithm.

[0050] refer to Figure 4 When mobile phone 100 executes a task, process A sends an IPC request to process B, and then process B forwards the IPC request to process C. Due to an exception in process C, it cannot return a message to process B, causing process B to also be unable to return a message to process A. When process A waits for a message to return from another process for a certain period of time, process A's response times out, triggering the ANR (Application Not Responding) mechanism. At this point, mobile phone 100 uses the LRU (Least Recently Active) algorithm to determine the most recently active processes in the system, collects their process information, and then outputs this information to allow developers to analyze the cause of process A triggering the ANR mechanism.

[0051] In some cases, if processes A, B, and C have all been active recently, the mobile phone 100 can use the LRU algorithm to collect and output the process information of processes A, B, and C. However, since the process information output by the mobile phone 100 does not include the communication relationships between processes A, B, and C, even if the developers obtain the process information of process C from the process information output by the mobile phone 100 and determine that process C has encountered an anomaly based on the process information of process C, they cannot determine whether process C needs to send a message to process A. Therefore, they cannot determine whether process A triggered the ANR mechanism because process C was abnormal, and thus cannot determine the reason why process A triggered the ANR mechanism.

[0052] In other cases, if process C has not been active recently, the phone 100 will not be able to collect process information for process C using the LRU algorithm, and therefore will not output process information for process C. As a result, developers cannot determine whether process C has encountered an anomaly based on the process information output by the phone 100, and thus cannot determine the reason why process A triggered the ANR mechanism, making proper maintenance impossible.

[0053] For example, in the above Figure 3B In the scenario shown, the camera service provider process (example of process C) is not started and is in an inactive state. When the camera process triggers the ANR mechanism, the phone 100, using the LRU algorithm, can only collect process information for the camera process (example of process A) and the camera service process (example of process B), but not for the camera service provider process. Therefore, the phone 100 can only output the process information for the camera process and the camera service process, but not the process information for the camera service provider process. This prevents developers from obtaining the process information for the camera service provider process, making it impossible to determine whether the camera service provider process has encountered an anomaly. Consequently, it's impossible to determine the true reason why the camera process triggered the ANR mechanism, hindering developers from properly maintaining the camera application's startup anomaly, potentially causing the camera application to malfunction again upon subsequent startups.

[0054] In view of this, embodiments of this application provide a method for determining abnormal processes. In this method, an electronic device can generate and store communication relationship information in real time, indicating the communication relationships between processes, based on the real-time communication relationships between them. For example, for the aforementioned... Figure 3BWhen the camera process sends an IPC request to the camera service process, communication relationship information between the camera process and the camera service process can be generated and stored. Similarly, when the camera service process sends an IPC request to the camera service provider process, communication relationship information between them can be generated and stored. When the first process of the electronic device is in an abnormal communication state (e.g., triggering an ANR mechanism, i.e., the waiting time for receiving messages reaches a first preset duration), the electronic device can, based on the stored communication relationship information, output the process information of all processes on each communication link in which the first process resides. This could be done by generating a log containing process information of all processes on each communication link in which the first process resides, or by recording the process information of all processes on each communication link in which the first process resides to corresponding files. For example, regarding the above... Figure 3B When the camera process triggers the ANR mechanism, the mobile phone 100 can output process information of the camera process, camera service process, and camera service provider process based on the stored communication relationship information. For example, it can generate a log containing process information of the camera process, camera service process, and camera service provider process, or record the process information of the camera process, camera service process, and camera service provider process to the corresponding file (such as plain text file, portable document format file (PDF), rich text format file (RTF), image, etc.).

[0055] It is understandable that communication relationship information is used to indicate the communication relationship (direct or indirect communication) between processes, and it can be stored in the form of tables, data structures, arrays, linked lists, structures, matrices, etc.

[0056] Since the abnormal process that causes the first process to trigger the ANR mechanism must be located on the communication link where the first process resides, the process information of all processes on each communication link where the electronic device outputs the first process's process information will inevitably include the abnormal process's process information. Therefore, developers can obtain the abnormal process's process information from the process information output by the electronic device, and thus determine the abnormal process that caused the first process to trigger the ANR mechanism. Based on this process information, they can then perform proper maintenance to prevent the first process from triggering the ANR mechanism again.

[0057] For example, refer to Figure 5Process A communicates with processes B and C, while process B communicates with processes D and F. The communication links for process A include three links: L01, L02, and L03. Processes on communication link L01 include A, B, and D; process A can communicate directly with process B, and process B can communicate directly with process D. Processes on communication link L02 include A, B, and F; process B can communicate directly with process F. Processes on communication link L03 include A and C; process A can communicate directly with process C. The electronic device can first generate and store communication relationship information indicating the communication relationships between processes A through F based on the communication relationships between them. Then, when process A triggers the ANR mechanism, the electronic device can output the process information of all processes on each communication link where process A resides, based on the pre-stored communication relationship information; that is, it can collect the process information of all processes on communication links L01, L02, and L03.

[0058] Specifically, the electronic device can first obtain the identifiers (such as process identifiers (PIDs), process names, etc.) of each process on each communication link where process A resides, then collect the process information corresponding to each identifier, and finally output the collected process information, that is, output the process information of processes A to F on communication links L01, L02, and L03. Since the abnormal process that causes process A to trigger the ANR mechanism must be one of processes A to F, the process information of processes A to F output by the electronic device must include the process information of the abnormal process. Thus, developers can determine the abnormal process that caused process A to trigger the ANR mechanism based on the process information output by the electronic device.

[0059] For example, refer to Figure 6 In the above Figure 1B and Figure 3B In the scenario shown, mobile phone 100 can generate and store corresponding communication relationship information in advance based on the communication relationships between the camera process, camera service process, and camera service provider process. Then, when the camera process triggers the ANR mechanism, mobile phone 100 can output the process information of the camera process, camera service process, and camera service provider process based on the pre-stored communication relationship information. Since the process information output by mobile phone 100 includes the process information of the camera service provider process, developers can determine that the camera service provider process has encountered an anomaly based on the process information output by mobile phone 100, thereby analyzing the reason why the camera process triggered the ANR mechanism.

[0060] The following section uses a table-based storage format as an example to introduce a storage scheme for communication relationship information.

[0061] Figure 7 The diagram illustrates the generation principle of communication link table M1.

[0062] refer to Figure 7 The communication process between processes in the electronic device's runtime system includes communication process T1 and communication process T2. In communication process T1, process P1 sends IPC requests to processes P2 and P3, process P2 sends IPC requests to processes P4 and P5, process P3 sends IPC requests to processes P6 and P7, process P4 sends an IPC request to process P6, and process P6 sends an IPC request to process P7. In communication process T2, process P9 sends an IPC request to process P10.

[0063] In some embodiments, the system kernel of the electronic device can, based on the direction of the IPC request, use each process in communication process T1 and communication process T2 as a communication node, and establish a communication topology diagram corresponding to communication process T1 and communication process T2 in real time. Then, based on the communication topology diagram corresponding to communication process T1 and communication process T2, a communication link table M1 is generated and stored. The communication link table M1 stores the communication relationship information between processes P1 to P10.

[0064] In other embodiments, the system kernel of the electronic device may not establish a communication topology diagram corresponding to communication process T1 and communication process T2, but directly generate and store the communication link table M1 based on the communication process of communication process T1 and communication process T2.

[0065] like Figure 7 As shown, rows 1-10 of the first column of the communication link table M1 store the communication nodes in the communication topology diagram corresponding to communication processes T1 and T2: processes P1 to P10. A process in the first column of the communication link table M1 has a direct communication relationship with other processes in the same row. For example, process P1 in the first row of the first column has direct communication relationships with processes P2 in the first row of the second column and P3 in the first row of the third column; process P2 in the second row of the first column has direct communication relationships with processes P4 in the second row of the second column and P5 in the second row of the third column; process P3 in the third row of the first column has direct communication relationships with processes P6 in the third row of the second column and P7 in the third row of the third column; process P4 in the fourth row of the first column has direct communication relationships with processes P6 in the fourth row of the second column; process P6 in the sixth row of the first column has direct communication relationships with processes P7 in the sixth row of the second column; and process P9 in the ninth row of the first column has direct communication relationships with processes P10 in the ninth row of the second column.

[0066] The following is combined Figure 8A and Figure 8B The process of generating the communication link table will be further explained.

[0067] Figures 8A-8B The diagram illustrates the generation principle of the communication link table M2.

[0068] refer to Figure 8A The communication process T3 between the various processes in the electronic device running system is as follows: process P1 sends IPC requests to process P2 and process P3 respectively, process P2 sends IPC requests to process P4 and process P5 respectively, and process P3 sends IPC requests to process P6.

[0069] In some embodiments, the system kernel of the electronic device can, based on the sending direction of the IPC request, treat each process in the communication process T3 as a communication node, establish a communication topology diagram corresponding to the communication process T3 in real time, and then generate a communication link M2 based on the communication topology diagram. Alternatively, the system kernel of the electronic device may not establish a communication topology diagram, but directly generate a communication link table M2 based on the communication process T3.

[0070] like Figure 8A As shown, the first column of communication list M2 is a vertex list of communication nodes, with rows 1 through 6 containing processes P1 through P6 from communication process T3 as vertices. Each cell in the first column of communication list M2 forms an adjacency list with the cells in its corresponding row. For example, the adjacency list of communication node P1 (the communication node corresponding to process P1) includes processes P1, P2, and P3; the adjacency list of communication node P2 includes processes P2, P4, and P5; and the adjacency list of communication node P3 includes processes P3 and P6.

[0071] In some cases, in the above Figure 8A Based on, refer to Figure 8B When process P3 sends an IPC request to process P7, the electronic device adds process P7 as the seventh vertex in the vertex list to the communication link list M2. Furthermore, the electronic device adds process P7 as a communication node to the third column of the adjacency list of P3's communication node, that is, it adds process P7 as a communication node to the third row and third column of the communication link list M2, indicating that there is a direct communication relationship between process P3 and process P7.

[0072] The following is based on Figure 8B The following example, using the communication link table M2, illustrates how to query the communication link table.

[0073] For example, when an electronic device detects that process P1 has triggered the ANR mechanism, it can first query the vertex list of communication link table M2 using the identifier of process P1 (such as PID, process name, etc.). Then, it queries the adjacent list corresponding to process P1 to find processes P2 and P3 that have a direct communication relationship with process P1. Next, it queries the adjacent list corresponding to process P2 to find processes P4 and P5 that have a direct communication relationship with process P2, and the adjacent list corresponding to process P3 to find processes P6 and P7 that have a direct communication relationship with process P3. Finally, if the electronic device finds that there are no other communication nodes corresponding to processes P4 through P7 in the adjacent list of the vertex list, it ends the query of communication link table M2. After the electronic device has queried communication link table M2 according to the above query method, it can output the process information of processes P1 through P7.

[0074] For example, when an electronic device detects that process P2 has triggered the ANR mechanism, it can first query the vertex list of the communication link table M2 using the identifier of process P2. Then, it queries the adjacency list corresponding to process P2 to find processes P4 and P5 that have a direct communication relationship with process P2. Finally, if the electronic device finds that there are no other communication nodes corresponding to processes P4 and P5 in their respective adjacency lists, it ends the query of the communication link table M2. After the electronic device has queried the communication link table M2 according to the above query method, it can output the process information of processes P2, P4, and P5.

[0075] In some embodiments, reference Figure 8C If process P5 terminates communication with process P2, the electronic device can remove process P5 from the vertex list of communication link table M2, and also remove process P5 from the adjacent list corresponding to process P2 in the vertex list of communication link table M2. The following is an illustrative example of how the electronic device outputs process information.

[0076] Figure 9 An example diagram showing how process information is output is illustrated.

[0077] refer to Figure 9 In the above Figure 8B In the scenario corresponding to the communication flow T3 shown, when process P1 triggers the ANR mechanism of the electronic device, the electronic device... Figure 8BIn the communication link table M2 shown, process information of process A and processes that have direct or indirect communication relationships with process A is obtained. Then, based on the level of process A and processes that have direct or indirect communication relationships with process A in the communication link of process A, the process information of process A and processes that have direct or indirect communication relationships with process A is output.

[0078] As mentioned above Figure 8B As shown, process P1 is at the first level, processes P2 and P3 are at the second level, and processes P4 to P7 are at the third level. Therefore, as Figure 9 As shown, the electronic device can output process information for process P1 at the first layer, process information for processes P2 and P3 that communicate directly with process P1 at the second layer, and process information for processes P4, P5, P6, and P7 that communicate indirectly with process P1 at the third layer. Processes P4 and P5 have direct communication relationships with process P2. Processes P6 and P7 have direct communication relationships with process P3.

[0079] In some embodiments, if the communication process T3 includes N layers of communication relationships, the electronic device can output N layers of process information, where N is a positive integer.

[0080] It is understandable that electronic devices output process information of each process according to the hierarchy of communication on the communication link. This helps developers determine the communication relationship between each process based on the output hierarchy of process information, and thus identify the abnormal process that caused a certain process to trigger the ANR mechanism based on the communication relationship.

[0081] It is understood that in this embodiment of the application, the communication link table is updated in real time, and the electronic device can also output the latest process information in the communication link table in real time.

[0082] Figure 10 A flowchart illustrating the method for determining abnormal processes provided in this application embodiment.

[0083] refer to Figure 10 The method includes the following steps:

[0084] S101: The electronic device detected that the first process is in an abnormal communication state.

[0085] In some embodiments, the electronic device detects that the first process is in an abnormal communication state by: detecting that the first process triggers an ANR mechanism, or detecting that the first process triggers a watchdog mechanism.

[0086] For example, refer to the above Figure 1B and Figure 1CWhen mobile phone 100 detects that the user clicks the camera application icon 11 on the desktop 10, mobile phone 100 starts the camera process (as an example of the first process), displays the preview interface 20, and sends an IPC request to the camera service process, and then waits for the camera service process to return a message. When the time for the camera process to wait for the camera service process to return a message reaches a first preset time, the camera process triggers the ANR mechanism and displays a prompt box 21 on the preview interface 20. At this time, mobile phone 100 detects that the camera process is in an abnormal communication state.

[0087] S102: The electronic device acquires the first communication relationship information of the first process, which includes the communication relationship information between each process downstream of the communication link in which the first process is located.

[0088] It can be understood that the processes downstream of the communication link where the first process is located refer to all processes on the communication link that send IPC requests after the first process. For example, if the first process is as described above... Figure 3B The camera process shown includes the camera service process and the camera service provider process, which are downstream processes of the communication link where the first process is located.

[0089] It should be noted that the first process downstream of the first process in the communication link is the process that sends the IPC request to the first process, and there is a direct communication relationship between them.

[0090] In some embodiments, the electronic device may retrieve the first communication relationship information of the first process from a pre-stored communication link table, using the identifier of the first process as an index. The communication link table includes communication relationship information of processes in various communications.

[0091] In some embodiments, the communication link table is obtained as follows: after the electronic device starts up, a blank table in the format corresponding to the communication link table is generated. Then, when a communication request is detected from a first process to a second process, the first communication relationship information of the first process is added to the blank table to obtain the communication link table. In this way, the communication relationship information of processes in various communications can be stored in the communication link table.

[0092] In some embodiments, the communication link table also includes second communication relationship information of the third process, which is added to the communication link table when the third process sends a communication request to the fourth process. The second communication relationship information includes the communication relationship between the third process and the fourth process. The second communication relationship information in the communication link table is deleted in the following case: the communication between the third process and the fourth process ends.

[0093] For example, when an electronic device detects that the third process and the fourth process have ended communication, the electronic device can delete the second communication relationship information of the third process from the communication link table to save storage space.

[0094] The specific process by which electronic devices obtain the communication link table can be found in the above. Figure 7 as well as Figures 8A-8C The relevant information will not be repeated here.

[0095] It is understood that, in addition to using a communication link table to store the communication relationship information between processes, this application embodiment may also use other forms to store the communication relationship information between processes, such as data structures, arrays, linked lists, structures, matrices, etc., without limitation.

[0096] S103: The electronic device obtains the process information of each process downstream of the communication link where the first process is located based on the first communication relationship information, wherein the process information includes the process information of the second process that causes the first process to be in an abnormal communication state.

[0097] In some embodiments, after the electronic device obtains the communication relationship information of the first process, it can output the process information of each process downstream of the communication link in which the first process is located, based on the first communication relationship information. Since this process information includes the information of the second process that causes the first process to be in an abnormal communication state, the developer can determine the second process that causes the first process to be in an abnormal communication state, i.e., the abnormal process that causes the first process to be in an abnormal communication state, based on this process information.

[0098] In some embodiments, the electronic device can determine the communication hierarchy of each process downstream of the communication link where the first process is located, based on a first communication relationship, and write the process information of each process downstream of the communication link where the first process is located into a first file according to the hierarchy. The first file includes, but is not limited to, logs, images, plain text files, portable document format files, rich text format files, etc.

[0099] In other embodiments, the electronic device may also output process information of a first process, and the process information of the first process is located at the first level.

[0100] It is understandable that the process information of each process is output according to the corresponding communication level on the communication link. This makes it easier for developers to determine the communication relationship between each process based on the level of the process information. This, in turn, makes it easier for developers to deduce the abnormal process that caused the first process to have an abnormal communication state based on the communication relationship between each process.

[0101] For example, refer to the above Figure 8AWhen the electronic device detects that process P1 (as the first process) triggers the ANR mechanism, the electronic device can use the PID of process P1 as an index to query the communication link table M2 for processes P1 to P7 that have a direct or indirect communication relationship with process P1, and then proceed according to the above... Figure 9 The output method shown outputs process information for processes P1 to P7.

[0102] It is understood that the abnormal process causing the first process to be in an abnormal communication state must be downstream of the communication link in which the first process is located. Therefore, in this embodiment, the process information of each process downstream of the communication link in which the first process is located, output by the electronic device, must include the process information of the abnormal process. In this way, developers can determine the abnormal process, i.e., the second process, that caused the communication abnormality of the first process based on the process information output by the electronic device. This allows developers to maintain the second process and prevent the first process from experiencing response abnormalities again.

[0103] It should be noted that the method for determining abnormal processes provided in this application embodiment can be applied to systems with... system, system, System, or The electronic devices of the system are not limited in this regard.

[0104] Figure 11 A schematic diagram of the structure of electronic device 1000 is shown. Electronic device 1000 can be any of the devices mentioned in this application, such as mobile phones, tablets, smart screens, wearable devices (e.g., watches, smart glasses, helmets), desktop computers, AR / VR devices, PDAs, and in-vehicle mobile devices (e.g., vehicle infotainment systems).

[0105] Electronic device 1000 may include processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity 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.

[0106] In some embodiments, the processor 110 can establish a corresponding communication relationship topology diagram in real time based on the communication relationships between various processes in the electronic device 1000, and generate a corresponding communication link table based on the communication relationship topology diagram. When the first process in the electronic device 1000 triggers the ANR mechanism, the processor 110 can output the process information of all processes on all communication links where the first process is located, based on the communication link table.

[0107] In some embodiments, the internal memory 121 may store communication relationship information between various processes in the electronic device 1000, as well as process information output by the electronic device 1000.

[0108] In some embodiments, when the first process of the electronic device triggers the ANR mechanism, the display screen 194 can display corresponding prompt information, such as the prompt box 21 mentioned in the above embodiments.

[0109] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 1000. In other embodiments of this application, the electronic device 1000 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0110] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU). In some embodiments, processor 110 may include one or more interfaces. Interfaces may include inter-integrated circuit (I2C) interfaces, inter-integrated circuit sound (I2S) interfaces, pulse code modulation (PCM) interfaces, universal asynchronous receiver / transmitter (UART) interfaces, mobile industry processor interfaces (MIPI), general-purpose input / output (GPIO) interfaces, and SIM card interfaces.

[0111] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via a USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the electronic device 1000. While charging the battery 142, the charging management module 140 can also supply power to the electronic device via the power management module 141.

[0112] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, providing power to the processor 110, internal memory 121, display screen 194, camera 193, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.

[0113] The wireless communication function of the electronic device 1000 can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor, and baseband processor.

[0114] The mobile communication module 150 can provide wireless communication solutions, including 2G / 3G / 4G / 5G, for use on the electronic device 1000. The wireless communication module 160 can provide wireless communication solutions, including wireless local area networks (WLANs) (such as Wi-Fi), Bluetooth, GNSS, frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies, for use on the electronic device 1000. In some embodiments, antenna 1 of the electronic device 1000 is coupled to the mobile communication module 150, and antenna 2 is coupled to the wireless communication module 160, enabling the electronic device 1000 to communicate with networks and other devices via wireless communication technologies.

[0115] Electronic device 1000 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0116] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device 1000 may include one or N display screens 194, where N is a positive integer greater than 1.

[0117] Electronic device 1000 can achieve shooting function through ISP, camera 193, video codec, GPU, display 194 and application processor.

[0118] The external storage 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 1000. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.

[0119] Internal memory 121 can be used to store computer executable program code, which includes instructions. Internal memory 121 may include a program storage area and a data storage area. Electronic device 1000 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.

[0120] The embodiments disclosed in this application can be implemented in hardware, software, firmware, or a combination of these implementation methods. Embodiments of this application can be implemented as computer programs or program code executable on a programmable system, the programmable system including at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.

[0121] Program code can be applied to input instructions to execute the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, the processing system includes any system having a processor such as, for example, a digital signal processor, a microcontroller, an application-specific integrated circuit, or a microprocessor.

[0122] The program code can be implemented using a high-level procedural language or an object-oriented programming language to communicate with the processing system. Assembly language or machine language can also be used when needed. In fact, the mechanisms described in this application are not limited to any particular programming language. In either case, the language can be a compiled language or an interpreted language.

[0123] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored thereon on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, the instructions may be distributed via a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine-readable (e.g., computer-readable) form, including but not limited to floppy disks, optical disks, optical discs, read-only memory, magneto-optical disks, random access memory, erasable programmable read-only memory, electrically erasable programmable read-only memory, magnetic cards or optical cards, flash memory, or tangible machine-readable storage for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in the form of electrical, optical, acoustic, or other propagation signals. Therefore, machine-readable media include any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a machine-readable (e.g., computer-readable) form.

[0124] In the accompanying drawings, some structural or methodological features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be necessary. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. Furthermore, the inclusion of structural or methodological features in a particular figure does not imply that such features are required in all embodiments, and in some embodiments, these features may be omitted or may be combined with other features.

[0125] It should be noted that all units / modules mentioned in the device embodiments of this application are logical units / modules. Physically, a logical unit / module can be a physical unit / module, a part of a physical unit / module, or a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important factor; the combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed in this application. Furthermore, to highlight the innovative aspects of this application, the above-described device embodiments of this application have not introduced units / modules that are not closely related to solving the technical problems proposed in this application. This does not mean that the above-described device embodiments do not contain other units / modules.

[0126] It should be noted that in the examples and description of this application, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0127] Although this application has been illustrated and described with reference to certain preferred embodiments thereof, those skilled in the art will understand that various changes in form and detail may be made thereto without departing from the scope of this application.

Claims

1. A method for determining abnormal processes, used in electronic devices, characterized in that, The method comprises: detecting that a first process is in an abnormal communication state; obtaining first communication relationship information of the first process, the first communication relationship information comprising a communication relationship between processes downstream of a communication link in which the first process is located; based on the first communication relationship information, obtaining process information of processes downstream of the communication link in which the first process is located, wherein the process information comprises process information of a second process that causes the first process to be in the abnormal communication state.

2. The method of claim 1, wherein, The detection that the first process is in an abnormal communication state comprises: detecting that the first process triggers an application unresponsive mechanism; or detecting that the first process triggers a watchdog mechanism.

3. The method of claim 1, wherein, The obtaining of the first communication relationship information of the first process comprises: obtaining the first communication relationship information of the first process from a communication link table through an identifier of the first process, wherein the communication link table comprises communication relationship information of processes in each communication.

4. The method of claim 3, wherein, The communication link table is obtained by: generating a blank table in a format corresponding to the communication link table; detecting that the first process sends a communication request to the second process; adding the first communication relationship information of the first process to the blank table to obtain the communication link table.

5. The method of claim 4, wherein, The communication link table further comprises second communication relationship information of a third process, the second communication relationship information being added to the communication link table when the third process sends a communication request to a fourth process, the second communication relationship information comprising a communication relationship between the third process and the fourth process, and the second communication relationship information in the communication link table is deleted in the following case: the third process and the fourth process end communication.

6. The method according to any one of claims 1 to 5, characterized in that, The obtaining of the process information of the first process and the processes downstream of the communication link in which the first process is located based on the first communication relationship information comprises: based on the first communication relationship information, determining a level at which the processes downstream of the communication link in which the first process is located communicate on the communication link; according to the level, writing the process information of the processes downstream of the communication link in which the first process is located into a first file.

7. The method of claim 6, wherein, The first file comprises at least one of the following: a log, a picture, a plain text file, a portable document format file, and a rich text format file.

8. An electronic device, comprising: comprise: 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, causes the electronic device to perform the method of any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the method of any one of claims 1 to 7.

10. A computer program product, characterized in that, comprise computer programs / instructions that, when executed, cause a computer to perform the method of any one of claims 1 to 7.